use of org.apache.hadoop.hive.serde2.lazy.LazySerDeParameters in project hive by apache.
the class TestSimpleMapEqualComparer method testIncompatibleType.
public void testIncompatibleType() throws SerDeException, IOException {
// empty maps
StringTextMapHolder o1 = new StringTextMapHolder();
StructObjectInspector oi1 = (StructObjectInspector) ObjectInspectorFactory.getReflectionObjectInspector(StringTextMapHolder.class, ObjectInspectorOptions.JAVA);
LazySimpleSerDe serde = new LazySimpleSerDe();
Configuration conf = new Configuration();
Properties tbl = new Properties();
tbl.setProperty(serdeConstants.LIST_COLUMNS, ObjectInspectorUtils.getFieldNames(oi1));
tbl.setProperty(serdeConstants.LIST_COLUMN_TYPES, ObjectInspectorUtils.getFieldTypes(oi1));
LazySerDeParameters serdeParams = new LazySerDeParameters(conf, tbl, LazySimpleSerDe.class.getName());
SerDeUtils.initializeSerDe(serde, conf, tbl, null);
ObjectInspector oi2 = serde.getObjectInspector();
Object o2 = serializeAndDeserialize(o1, oi1, serde, serdeParams);
int rc = ObjectInspectorUtils.compare(o1, oi1, o2, oi2, new SimpleMapEqualComparer());
assertEquals(0, rc);
// equal maps
o1.mMap.put("42", new Text("The answer to Life, Universe And Everything"));
o1.mMap.put("1729", new Text("A taxi cab number"));
o2 = serializeAndDeserialize(o1, oi1, serde, serdeParams);
rc = ObjectInspectorUtils.compare(o1, oi1, o2, oi2, new SimpleMapEqualComparer());
assertFalse(0 == rc);
}
use of org.apache.hadoop.hive.serde2.lazy.LazySerDeParameters in project hive by apache.
the class TestCrossMapEqualComparer method testCompatibleType.
public void testCompatibleType() throws SerDeException, IOException {
// empty maps
TextStringMapHolder o1 = new TextStringMapHolder();
StructObjectInspector oi1 = (StructObjectInspector) ObjectInspectorFactory.getReflectionObjectInspector(TextStringMapHolder.class, ObjectInspectorOptions.JAVA);
LazySimpleSerDe serde = new LazySimpleSerDe();
Configuration conf = new Configuration();
Properties tbl = new Properties();
tbl.setProperty(serdeConstants.LIST_COLUMNS, ObjectInspectorUtils.getFieldNames(oi1));
tbl.setProperty(serdeConstants.LIST_COLUMN_TYPES, ObjectInspectorUtils.getFieldTypes(oi1));
LazySerDeParameters serdeParams = new LazySerDeParameters(conf, tbl, LazySimpleSerDe.class.getName());
SerDeUtils.initializeSerDe(serde, conf, tbl, null);
ObjectInspector oi2 = serde.getObjectInspector();
Object o2 = serializeAndDeserialize(o1, oi1, serde, serdeParams);
int rc = ObjectInspectorUtils.compare(o1, oi1, o2, oi2, new CrossMapEqualComparer());
assertEquals(0, rc);
// equal maps
o1.mMap.put(new Text("42"), "The answer to Life, Universe And Everything");
o1.mMap.put(new Text("1729"), "A taxi cab number");
o2 = serializeAndDeserialize(o1, oi1, serde, serdeParams);
rc = ObjectInspectorUtils.compare(o1, oi1, o2, oi2, new CrossMapEqualComparer());
assertEquals(0, rc);
// unequal maps
o1.mMap.put(new Text("1729"), "Hardy-Ramanujan Number");
rc = ObjectInspectorUtils.compare(o1, oi1, o2, oi2, new CrossMapEqualComparer());
assertFalse(0 == rc);
}
use of org.apache.hadoop.hive.serde2.lazy.LazySerDeParameters in project hive by apache.
the class TestCrossMapEqualComparer method testIncompatibleType.
public void testIncompatibleType() throws SerDeException, IOException {
// empty maps
StringTextMapHolder o1 = new StringTextMapHolder();
StructObjectInspector oi1 = (StructObjectInspector) ObjectInspectorFactory.getReflectionObjectInspector(StringTextMapHolder.class, ObjectInspectorOptions.JAVA);
LazySimpleSerDe serde = new LazySimpleSerDe();
Configuration conf = new Configuration();
Properties tbl = new Properties();
tbl.setProperty(serdeConstants.LIST_COLUMNS, ObjectInspectorUtils.getFieldNames(oi1));
tbl.setProperty(serdeConstants.LIST_COLUMN_TYPES, ObjectInspectorUtils.getFieldTypes(oi1));
LazySerDeParameters serdeParams = new LazySerDeParameters(conf, tbl, LazySimpleSerDe.class.getName());
SerDeUtils.initializeSerDe(serde, conf, tbl, null);
ObjectInspector oi2 = serde.getObjectInspector();
Object o2 = serializeAndDeserialize(o1, oi1, serde, serdeParams);
int rc = ObjectInspectorUtils.compare(o1, oi1, o2, oi2, new CrossMapEqualComparer());
assertEquals(0, rc);
// equal maps
o1.mMap.put("42", new Text("The answer to Life, Universe And Everything"));
o1.mMap.put("1729", new Text("A taxi cab number"));
o2 = serializeAndDeserialize(o1, oi1, serde, serdeParams);
rc = ObjectInspectorUtils.compare(o1, oi1, o2, oi2, new CrossMapEqualComparer());
assertEquals(0, rc);
// unequal maps
o1.mMap.put("1729", new Text("Hardy-Ramanujan Number"));
rc = ObjectInspectorUtils.compare(o1, oi1, o2, oi2, new CrossMapEqualComparer());
assertFalse(0 == rc);
}
use of org.apache.hadoop.hive.serde2.lazy.LazySerDeParameters in project hive by apache.
the class AccumuloSerDe method initialize.
public void initialize(Configuration conf, Properties properties) throws SerDeException {
accumuloSerDeParameters = new AccumuloSerDeParameters(conf, properties, getClass().getName());
final LazySerDeParameters serDeParams = accumuloSerDeParameters.getSerDeParameters();
final List<ColumnMapping> mappings = accumuloSerDeParameters.getColumnMappings();
final List<TypeInfo> columnTypes = accumuloSerDeParameters.getHiveColumnTypes();
final AccumuloRowIdFactory factory = accumuloSerDeParameters.getRowIdFactory();
ArrayList<ObjectInspector> columnObjectInspectors = getColumnObjectInspectors(columnTypes, serDeParams, mappings, factory);
cachedObjectInspector = LazyObjectInspectorFactory.getLazySimpleStructObjectInspector(serDeParams.getColumnNames(), columnObjectInspectors, serDeParams.getSeparators()[0], serDeParams.getNullSequence(), serDeParams.isLastColumnTakesRest(), serDeParams.isEscaped(), serDeParams.getEscapeChar());
cachedRow = new LazyAccumuloRow((LazySimpleStructObjectInspector) cachedObjectInspector);
serializer = new AccumuloRowSerializer(accumuloSerDeParameters.getRowIdOffset(), accumuloSerDeParameters.getSerDeParameters(), accumuloSerDeParameters.getColumnMappings(), accumuloSerDeParameters.getTableVisibilityLabel(), accumuloSerDeParameters.getRowIdFactory());
if (log.isInfoEnabled()) {
log.info("Initialized with {} type: {}", accumuloSerDeParameters.getSerDeParameters().getColumnNames(), accumuloSerDeParameters.getSerDeParameters().getColumnTypes());
}
}
use of org.apache.hadoop.hive.serde2.lazy.LazySerDeParameters 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