Search in sources :

Example 1 with AvroHBaseValueFactory

use of org.apache.hadoop.hive.hbase.struct.AvroHBaseValueFactory in project hive by apache.

the class HBaseSerDeParameters method createValueFactories.

private List<HBaseValueFactory> createValueFactories(Configuration conf, Properties tbl) throws SerDeException {
    List<HBaseValueFactory> valueFactories = new ArrayList<HBaseValueFactory>();
    try {
        for (int i = 0; i < columnMappings.size(); i++) {
            String serType = getSerializationType(conf, tbl, columnMappings.getColumnsMapping()[i]);
            if (AVRO_SERIALIZATION_TYPE.equals(serType)) {
                Schema schema = getSchema(conf, tbl, columnMappings.getColumnsMapping()[i]);
                valueFactories.add(new AvroHBaseValueFactory(i, schema));
            } else if (STRUCT_SERIALIZATION_TYPE.equals(serType)) {
                String structValueClassName = tbl.getProperty(HBaseSerDe.HBASE_STRUCT_SERIALIZER_CLASS);
                if (structValueClassName == null) {
                    throw new IllegalArgumentException(HBaseSerDe.HBASE_STRUCT_SERIALIZER_CLASS + " must be set for hbase columns of type [" + STRUCT_SERIALIZATION_TYPE + "]");
                }
                Class<?> structValueClass = loadClass(structValueClassName, job);
                valueFactories.add(new StructHBaseValueFactory(i, structValueClass));
            } else {
                valueFactories.add(new DefaultHBaseValueFactory(i));
            }
        }
    } catch (Exception e) {
        throw new SerDeException(e);
    }
    return valueFactories;
}
Also used : DefaultHBaseValueFactory(org.apache.hadoop.hive.hbase.struct.DefaultHBaseValueFactory) Schema(org.apache.avro.Schema) ArrayList(java.util.ArrayList) SerDeException(org.apache.hadoop.hive.serde2.SerDeException) StructHBaseValueFactory(org.apache.hadoop.hive.hbase.struct.StructHBaseValueFactory) StructHBaseValueFactory(org.apache.hadoop.hive.hbase.struct.StructHBaseValueFactory) HBaseValueFactory(org.apache.hadoop.hive.hbase.struct.HBaseValueFactory) AvroHBaseValueFactory(org.apache.hadoop.hive.hbase.struct.AvroHBaseValueFactory) DefaultHBaseValueFactory(org.apache.hadoop.hive.hbase.struct.DefaultHBaseValueFactory) AvroHBaseValueFactory(org.apache.hadoop.hive.hbase.struct.AvroHBaseValueFactory) SerDeException(org.apache.hadoop.hive.serde2.SerDeException)

Aggregations

ArrayList (java.util.ArrayList)1 Schema (org.apache.avro.Schema)1 AvroHBaseValueFactory (org.apache.hadoop.hive.hbase.struct.AvroHBaseValueFactory)1 DefaultHBaseValueFactory (org.apache.hadoop.hive.hbase.struct.DefaultHBaseValueFactory)1 HBaseValueFactory (org.apache.hadoop.hive.hbase.struct.HBaseValueFactory)1 StructHBaseValueFactory (org.apache.hadoop.hive.hbase.struct.StructHBaseValueFactory)1 SerDeException (org.apache.hadoop.hive.serde2.SerDeException)1