Search in sources :

Example 1 with HiveAccumuloRowIdColumnMapping

use of org.apache.hadoop.hive.accumulo.columns.HiveAccumuloRowIdColumnMapping in project hive by apache.

the class TestHiveAccumuloTableInputFormat method testColumnMappingsToPairs.

@Test
public void testColumnMappingsToPairs() {
    List<ColumnMapping> mappings = new ArrayList<ColumnMapping>();
    Set<Pair<Text, Text>> columns = new HashSet<Pair<Text, Text>>();
    // Row ID
    mappings.add(new HiveAccumuloRowIdColumnMapping(AccumuloHiveConstants.ROWID, ColumnEncoding.STRING, "row", TypeInfoFactory.stringTypeInfo.toString()));
    // Some cf:cq
    mappings.add(new HiveAccumuloColumnMapping("person", "name", ColumnEncoding.STRING, "col1", TypeInfoFactory.stringTypeInfo.toString()));
    mappings.add(new HiveAccumuloColumnMapping("person", "age", ColumnEncoding.STRING, "col2", TypeInfoFactory.stringTypeInfo.toString()));
    mappings.add(new HiveAccumuloColumnMapping("person", "height", ColumnEncoding.STRING, "col3", TypeInfoFactory.stringTypeInfo.toString()));
    // Bare cf
    mappings.add(new HiveAccumuloColumnMapping("city", "name", ColumnEncoding.STRING, "col4", TypeInfoFactory.stringTypeInfo.toString()));
    columns.add(new Pair<Text, Text>(new Text("person"), new Text("name")));
    columns.add(new Pair<Text, Text>(new Text("person"), new Text("age")));
    columns.add(new Pair<Text, Text>(new Text("person"), new Text("height")));
    // Null qualifier would mean all qualifiers in that family, want an empty qualifier
    columns.add(new Pair<Text, Text>(new Text("city"), new Text("name")));
    assertEquals(columns, inputformat.getPairCollection(mappings));
}
Also used : HiveAccumuloRowIdColumnMapping(org.apache.hadoop.hive.accumulo.columns.HiveAccumuloRowIdColumnMapping) ArrayList(java.util.ArrayList) Text(org.apache.hadoop.io.Text) HiveAccumuloColumnMapping(org.apache.hadoop.hive.accumulo.columns.HiveAccumuloColumnMapping) ColumnMapping(org.apache.hadoop.hive.accumulo.columns.ColumnMapping) HiveAccumuloColumnMapping(org.apache.hadoop.hive.accumulo.columns.HiveAccumuloColumnMapping) HiveAccumuloRowIdColumnMapping(org.apache.hadoop.hive.accumulo.columns.HiveAccumuloRowIdColumnMapping) Pair(org.apache.accumulo.core.util.Pair) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 2 with HiveAccumuloRowIdColumnMapping

use of org.apache.hadoop.hive.accumulo.columns.HiveAccumuloRowIdColumnMapping in project hive by apache.

the class TestAccumuloRangeGenerator method setup.

@Before
public void setup() {
    handler = AccumuloPredicateHandler.getInstance();
    rowIdMapping = new HiveAccumuloRowIdColumnMapping(AccumuloHiveConstants.ROWID, ColumnEncoding.STRING, "row", TypeInfoFactory.stringTypeInfo.toString());
    conf = new Configuration(true);
}
Also used : Configuration(org.apache.hadoop.conf.Configuration) HiveAccumuloRowIdColumnMapping(org.apache.hadoop.hive.accumulo.columns.HiveAccumuloRowIdColumnMapping) Before(org.junit.Before)

Example 3 with HiveAccumuloRowIdColumnMapping

use of org.apache.hadoop.hive.accumulo.columns.HiveAccumuloRowIdColumnMapping in project hive by apache.

the class LazyAccumuloRow method uncheckedGetField.

/*
   * split pairs by delimiter.
   */
private Object uncheckedGetField(int id) {
    if (getFieldInited()[id]) {
        return getFields()[id].getObject();
    }
    getFieldInited()[id] = true;
    ColumnMapping columnMapping = columnMappings.get(id);
    LazyObjectBase field = getFields()[id];
    if (columnMapping instanceof HiveAccumuloMapColumnMapping) {
        HiveAccumuloMapColumnMapping mapColumnMapping = (HiveAccumuloMapColumnMapping) columnMapping;
        LazyAccumuloMap map = (LazyAccumuloMap) field;
        map.init(row, mapColumnMapping);
    } else {
        byte[] value;
        if (columnMapping instanceof HiveAccumuloRowIdColumnMapping) {
            // Use the rowID directly
            value = row.getRowId().getBytes();
        } else if (columnMapping instanceof HiveAccumuloColumnMapping) {
            HiveAccumuloColumnMapping accumuloColumnMapping = (HiveAccumuloColumnMapping) columnMapping;
            // Use the colfam and colqual to get the value
            value = row.getValue(new Text(accumuloColumnMapping.getColumnFamilyBytes()), new Text(accumuloColumnMapping.getColumnQualifierBytes()));
        } else {
            log.error("Could not process ColumnMapping of type " + columnMapping.getClass() + " at offset " + id + " in column mapping: " + columnMapping.getMappingSpec());
            throw new IllegalArgumentException("Cannot process ColumnMapping of type " + columnMapping.getClass());
        }
        if (value == null || isNull(oi.getNullSequence(), value, 0, value.length)) {
            field.setNull();
        } else {
            ByteArrayRef ref = new ByteArrayRef();
            ref.setData(value);
            field.init(ref, 0, value.length);
        }
    }
    return field.getObject();
}
Also used : ByteArrayRef(org.apache.hadoop.hive.serde2.lazy.ByteArrayRef) HiveAccumuloRowIdColumnMapping(org.apache.hadoop.hive.accumulo.columns.HiveAccumuloRowIdColumnMapping) HiveAccumuloMapColumnMapping(org.apache.hadoop.hive.accumulo.columns.HiveAccumuloMapColumnMapping) LazyObjectBase(org.apache.hadoop.hive.serde2.lazy.LazyObjectBase) Text(org.apache.hadoop.io.Text) HiveAccumuloColumnMapping(org.apache.hadoop.hive.accumulo.columns.HiveAccumuloColumnMapping) HiveAccumuloMapColumnMapping(org.apache.hadoop.hive.accumulo.columns.HiveAccumuloMapColumnMapping) HiveAccumuloColumnMapping(org.apache.hadoop.hive.accumulo.columns.HiveAccumuloColumnMapping) HiveAccumuloRowIdColumnMapping(org.apache.hadoop.hive.accumulo.columns.HiveAccumuloRowIdColumnMapping) ColumnMapping(org.apache.hadoop.hive.accumulo.columns.ColumnMapping)

Example 4 with HiveAccumuloRowIdColumnMapping

use of org.apache.hadoop.hive.accumulo.columns.HiveAccumuloRowIdColumnMapping in project hive by apache.

the class AccumuloSerDe method getColumnObjectInspectors.

protected ArrayList<ObjectInspector> getColumnObjectInspectors(List<TypeInfo> columnTypes, LazySerDeParameters serDeParams, List<ColumnMapping> mappings, AccumuloRowIdFactory factory) throws SerDeException {
    ArrayList<ObjectInspector> columnObjectInspectors = new ArrayList<ObjectInspector>(columnTypes.size());
    for (int i = 0; i < columnTypes.size(); i++) {
        TypeInfo type = columnTypes.get(i);
        ColumnMapping mapping = mappings.get(i);
        if (mapping instanceof HiveAccumuloRowIdColumnMapping) {
            columnObjectInspectors.add(factory.createRowIdObjectInspector(type));
        } else {
            columnObjectInspectors.add(LazyFactory.createLazyObjectInspector(type, serDeParams.getSeparators(), 1, serDeParams.getNullSequence(), serDeParams.isEscaped(), serDeParams.getEscapeChar()));
        }
    }
    return columnObjectInspectors;
}
Also used : LazySimpleStructObjectInspector(org.apache.hadoop.hive.serde2.lazy.objectinspector.LazySimpleStructObjectInspector) ObjectInspector(org.apache.hadoop.hive.serde2.objectinspector.ObjectInspector) HiveAccumuloRowIdColumnMapping(org.apache.hadoop.hive.accumulo.columns.HiveAccumuloRowIdColumnMapping) ArrayList(java.util.ArrayList) TypeInfo(org.apache.hadoop.hive.serde2.typeinfo.TypeInfo) HiveAccumuloRowIdColumnMapping(org.apache.hadoop.hive.accumulo.columns.HiveAccumuloRowIdColumnMapping) ColumnMapping(org.apache.hadoop.hive.accumulo.columns.ColumnMapping)

Aggregations

HiveAccumuloRowIdColumnMapping (org.apache.hadoop.hive.accumulo.columns.HiveAccumuloRowIdColumnMapping)4 ColumnMapping (org.apache.hadoop.hive.accumulo.columns.ColumnMapping)3 ArrayList (java.util.ArrayList)2 HiveAccumuloColumnMapping (org.apache.hadoop.hive.accumulo.columns.HiveAccumuloColumnMapping)2 Text (org.apache.hadoop.io.Text)2 HashSet (java.util.HashSet)1 Pair (org.apache.accumulo.core.util.Pair)1 Configuration (org.apache.hadoop.conf.Configuration)1 HiveAccumuloMapColumnMapping (org.apache.hadoop.hive.accumulo.columns.HiveAccumuloMapColumnMapping)1 ByteArrayRef (org.apache.hadoop.hive.serde2.lazy.ByteArrayRef)1 LazyObjectBase (org.apache.hadoop.hive.serde2.lazy.LazyObjectBase)1 LazySimpleStructObjectInspector (org.apache.hadoop.hive.serde2.lazy.objectinspector.LazySimpleStructObjectInspector)1 ObjectInspector (org.apache.hadoop.hive.serde2.objectinspector.ObjectInspector)1 TypeInfo (org.apache.hadoop.hive.serde2.typeinfo.TypeInfo)1 Before (org.junit.Before)1 Test (org.junit.Test)1