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));
}
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);
}
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();
}
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;
}
Aggregations