Search in sources :

Example 1 with AllTypes

use of org.apache.hadoop.hive.ql.io.protobuf.SampleProtos.AllTypes in project hive by apache.

the class TestProtoMessageSerDe method testAll.

@Test
public void testAll() throws Exception {
    ProtoMessageWritable<AllTypes> writable = init(AllTypes.class, "MapFieldEntry");
    ObjectInspector oi = structoi(list("doubleType", "floatType", "int32Type", "int64Type", "uint32Type", "uint64Type", "sint32Type", "sint64Type", "fixed32Type", "fixed64Type", "sfixed32Type", "sfixed64Type", "boolType", "stringType", "bytesType", "mapType", "stringListType", "messageType", "messageListType", "enumType"), list(PrimitiveObjectInspectorFactory.javaDoubleObjectInspector, PrimitiveObjectInspectorFactory.javaFloatObjectInspector, PrimitiveObjectInspectorFactory.javaIntObjectInspector, PrimitiveObjectInspectorFactory.javaLongObjectInspector, PrimitiveObjectInspectorFactory.javaIntObjectInspector, PrimitiveObjectInspectorFactory.javaLongObjectInspector, PrimitiveObjectInspectorFactory.javaIntObjectInspector, PrimitiveObjectInspectorFactory.javaLongObjectInspector, PrimitiveObjectInspectorFactory.javaIntObjectInspector, PrimitiveObjectInspectorFactory.javaLongObjectInspector, PrimitiveObjectInspectorFactory.javaIntObjectInspector, PrimitiveObjectInspectorFactory.javaLongObjectInspector, PrimitiveObjectInspectorFactory.javaBooleanObjectInspector, PrimitiveObjectInspectorFactory.javaStringObjectInspector, PrimitiveObjectInspectorFactory.javaByteArrayObjectInspector, strmapoi, listoi(stroi), m1oi, listoi(m1oi), stroi));
    assertEquals(oi, serde.getObjectInspector());
    writable.setMessage(AllTypes.getDefaultInstance());
    assertArrayEquals(arr(null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null), (Object[]) serde.deserialize(writable));
    AllTypes proto = AllTypes.newBuilder().setDoubleType(1.0).setFloatType(2.0f).setInt32Type(3).setInt64Type(4).setUint32Type(5).setUint64Type(6).setSint32Type(7).setSint64Type(8).setFixed32Type(9).setFixed64Type(10).setSfixed32Type(11).setSfixed64Type(12).setBoolType(true).setStringType("val13").setBytesType(ByteString.copyFrom(new byte[] { 14, 15 })).addMapType(makeMap(16)).addMapType(makeMap(17)).addStringListType("val18").addStringListType("val19").setMessageType(makeMesg1(19)).addMessageListType(makeMesg1(24)).addMessageListType(makeMesg1(29)).setEnumType(Enum1.VAL1).build();
    writable.setMessage(proto);
    assertArrayEquals(arr(1.0d, 2.0f, 3, 4L, 5, 6L, 7, 8L, 9, 10L, 11, 12L, true, "val13", new byte[] { 14, 15 }, map("key16", "val16", "key17", "val17"), arr("val18", "val19"), arr(map("key20", "val20", "key21", "val21"), arr("key22", "val22"), arr(23, 24)), arr(arr(map("key25", "val25", "key26", "val26"), arr("key27", "val27"), arr(28, 29)), arr(map("key30", "val30", "key31", "val31"), arr("key32", "val32"), arr(33, 34))), "VAL1"), (Object[]) serde.deserialize(writable));
}
Also used : ObjectInspector(org.apache.hadoop.hive.serde2.objectinspector.ObjectInspector) AllTypes(org.apache.hadoop.hive.ql.io.protobuf.SampleProtos.AllTypes) Test(org.junit.Test)

Aggregations

AllTypes (org.apache.hadoop.hive.ql.io.protobuf.SampleProtos.AllTypes)1 ObjectInspector (org.apache.hadoop.hive.serde2.objectinspector.ObjectInspector)1 Test (org.junit.Test)1