Search in sources :

Example 36 with SerDeException

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();
}
Also used : HashSet(java.util.HashSet) TSet(org.apache.thrift.protocol.TSet) Set(java.util.Set) ListObjectInspector(org.apache.hadoop.hive.serde2.objectinspector.ListObjectInspector) TSet(org.apache.thrift.protocol.TSet)

Example 37 with SerDeException

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));
}
Also used : ShortObjectInspector(org.apache.hadoop.hive.serde2.objectinspector.primitive.ShortObjectInspector)

Example 38 with SerDeException

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));
}
Also used : IntObjectInspector(org.apache.hadoop.hive.serde2.objectinspector.primitive.IntObjectInspector)

Example 39 with SerDeException

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));
}
Also used : LongObjectInspector(org.apache.hadoop.hive.serde2.objectinspector.primitive.LongObjectInspector)

Example 40 with SerDeException

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));
}
Also used : Schema(org.apache.avro.Schema) GenericData(org.apache.avro.generic.GenericData) UnionObjectInspector(org.apache.hadoop.hive.serde2.objectinspector.UnionObjectInspector) Test(org.junit.Test)

Aggregations

SerDeException (org.apache.hadoop.hive.serde2.SerDeException)124 StructObjectInspector (org.apache.hadoop.hive.serde2.objectinspector.StructObjectInspector)108 ObjectInspector (org.apache.hadoop.hive.serde2.objectinspector.ObjectInspector)100 ArrayList (java.util.ArrayList)98 Properties (java.util.Properties)59 Test (org.junit.Test)59 Configuration (org.apache.hadoop.conf.Configuration)52 TypeInfo (org.apache.hadoop.hive.serde2.typeinfo.TypeInfo)52 Text (org.apache.hadoop.io.Text)50 IOException (java.io.IOException)37 ListObjectInspector (org.apache.hadoop.hive.serde2.objectinspector.ListObjectInspector)33 Schema (org.apache.avro.Schema)31 StructField (org.apache.hadoop.hive.serde2.objectinspector.StructField)31 MapObjectInspector (org.apache.hadoop.hive.serde2.objectinspector.MapObjectInspector)28 PrimitiveObjectInspector (org.apache.hadoop.hive.serde2.objectinspector.PrimitiveObjectInspector)28 PrimitiveTypeInfo (org.apache.hadoop.hive.serde2.typeinfo.PrimitiveTypeInfo)24 Put (org.apache.hadoop.hbase.client.Put)22 LazySerDeParameters (org.apache.hadoop.hive.serde2.lazy.LazySerDeParameters)22 IntWritable (org.apache.hadoop.io.IntWritable)22 HiveException (org.apache.hadoop.hive.ql.metadata.HiveException)21