/** * Auto-generate the avro struct from schema * * @param schemaLiteral schema for the avro struct as string * @param sb StringBuilder to hold the generated struct * @throws SerDeException if something goes wrong while generating the struct * */ private static void generateAvroStructFromSchema(String schemaLiteral, StringBuilder sb) throws SerDeException { Schema schema = Schema.parse(schemaLiteral); generateAvroStructFromSchema(schema, sb); }
/** * Auto-generates the column struct * * @param serType serialization type * @param serClassName serialization class name * @param schemaLiteral schema string * @param colMap hbase column mapping * @param sb StringBuilder to hold the generated struct * @throws SerDeException if something goes wrong while generating the struct * */ private static void generateColumnStruct(String serType, String serClassName, String schemaLiteral, ColumnMapping colMap, StringBuilder sb) throws SerDeException { if (serType.equalsIgnoreCase(AVRO_SERIALIZATION_TYPE)) { if (serClassName != null) { generateAvroStructFromClass(serClassName, sb); } else { generateAvroStructFromSchema(schemaLiteral, sb); } } else { throw new SerDeException("Unknown " + HBaseSerDe.SERIALIZATION_TYPE + " found for column family [" + colMap.familyName + "]"); } }
/** * Auto-generate the avro struct from class * * @param serClassName serialization class for avro struct * @param sb StringBuilder to hold the generated struct * @throws SerDeException if something goes wrong while generating the struct * */ private static void generateAvroStructFromClass(String serClassName, StringBuilder sb) throws SerDeException { Class<?> serClass; try { serClass = JavaUtils.loadClass(serClassName); } catch (ClassNotFoundException e) { throw new SerDeException("Error obtaining descriptor for " + serClassName, e); } Schema schema = ReflectData.get().getSchema(serClass); generateAvroStructFromSchema(schema, sb); }
/** * Auto-generate the avro struct from schema * * @param schemaLiteral schema for the avro struct as string * @param sb StringBuilder to hold the generated struct * @throws SerDeException if something goes wrong while generating the struct * */ private static void generateAvroStructFromSchema(String schemaLiteral, StringBuilder sb) throws SerDeException { Schema schema = Schema.parse(schemaLiteral); generateAvroStructFromSchema(schema, sb); }
/** * Auto-generates the column struct * * @param serType serialization type * @param serClassName serialization class name * @param schemaLiteral schema string * @param colMap hbase column mapping * @param sb StringBuilder to hold the generated struct * @throws SerDeException if something goes wrong while generating the struct * */ private static void generateColumnStruct(String serType, String serClassName, String schemaLiteral, ColumnMapping colMap, StringBuilder sb) throws SerDeException { if (serType.equalsIgnoreCase(AVRO_SERIALIZATION_TYPE)) { if (serClassName != null) { generateAvroStructFromClass(serClassName, sb); } else { generateAvroStructFromSchema(schemaLiteral, sb); } } else { throw new SerDeException("Unknown " + HBaseSerDe.SERIALIZATION_TYPE + " found for column family [" + colMap.familyName + "]"); } }
/** * Auto-generate the avro struct from class * * @param serClassName serialization class for avro struct * @param sb StringBuilder to hold the generated struct * @throws SerDeException if something goes wrong while generating the struct * */ private static void generateAvroStructFromClass(String serClassName, StringBuilder sb) throws SerDeException { Class<?> serClass; try { serClass = JavaUtils.loadClass(serClassName); } catch (ClassNotFoundException e) { throw new SerDeException("Error obtaining descriptor for " + serClassName, e); } Schema schema = ReflectData.get().getSchema(serClass); generateAvroStructFromSchema(schema, sb); }