use of org.apache.hadoop.hive.serde2.SerDeException in project hive by apache.
the class DynamicSerDeTypeSet method serialize.
@Override
public void serialize(Object o, ObjectInspector oi, TProtocol oprot) throws TException, SerDeException, NoSuchFieldException, IllegalAccessException {
ListObjectInspector loi = (ListObjectInspector) oi;
Set<Object> set = (Set<Object>) o;
DynamicSerDeTypeBase mt = getElementType();
tset = new TSet(mt.getType(), set.size());
oprot.writeSetBegin(tset);
for (Object element : set) {
mt.serialize(element, loi.getListElementObjectInspector(), oprot);
}
// in theory, the below call isn't needed in non thrift_mode, but let's not
// get too crazy
oprot.writeSetEnd();
}
use of org.apache.hadoop.hive.serde2.SerDeException in project hive by apache.
the class DynamicSerDeTypei16 method serialize.
@Override
public void serialize(Object o, ObjectInspector oi, TProtocol oprot) throws TException, SerDeException, NoSuchFieldException, IllegalAccessException {
ShortObjectInspector poi = (ShortObjectInspector) oi;
oprot.writeI16(poi.get(o));
}
use of org.apache.hadoop.hive.serde2.SerDeException in project hive by apache.
the class DynamicSerDeTypei32 method serialize.
@Override
public void serialize(Object o, ObjectInspector oi, TProtocol oprot) throws TException, SerDeException, NoSuchFieldException, IllegalAccessException {
IntObjectInspector poi = (IntObjectInspector) oi;
oprot.writeI32(poi.get(o));
}
use of org.apache.hadoop.hive.serde2.SerDeException in project hive by apache.
the class DynamicSerDeTypei64 method serialize.
@Override
public void serialize(Object o, ObjectInspector oi, TProtocol oprot) throws TException, SerDeException, NoSuchFieldException, IllegalAccessException {
LongObjectInspector poi = (LongObjectInspector) oi;
oprot.writeI64(poi.get(o));
}
use of org.apache.hadoop.hive.serde2.SerDeException in project hive by apache.
the class TestAvroDeserializer method canDeserializeEvolvedUnions1.
@Test
public void canDeserializeEvolvedUnions1() throws SerDeException, IOException {
Schema ws = AvroSerdeUtils.getSchemaFor(TestAvroObjectInspectorGenerator.UNION_SCHEMA);
Schema rs = AvroSerdeUtils.getSchemaFor(TestAvroObjectInspectorGenerator.UNION_SCHEMA_2);
GenericData.Record record = new GenericData.Record(ws);
record.put("aUnion", "this is a string");
ResultPair result = unionTester(ws, rs, record);
assertTrue(result.value instanceof String);
assertEquals("this is a string", result.value);
UnionObjectInspector uoi = (UnionObjectInspector) result.oi;
// The null in union type should be removed
assertEquals(1, uoi.getTag(result.unionObject));
// Now the other enum possibility
record = new GenericData.Record(ws);
record.put("aUnion", 99);
result = unionTester(ws, rs, record);
assertTrue(result.value instanceof Integer);
assertEquals(99, result.value);
uoi = (UnionObjectInspector) result.oi;
// The null in union type should be removed
assertEquals(0, uoi.getTag(result.unionObject));
}
Aggregations