use of org.apache.hadoop.hive.serde2.binarysortable.MyTestClass in project hive by apache.
the class TestStatsSerde method testLazyBinarySerDe.
/**
* Test LazyBinarySerDe
*/
@Test
public void testLazyBinarySerDe() throws Throwable {
try {
System.out.println("test: testLazyBinarySerDe");
int num = 1000;
Random r = new Random(1234);
MyTestClass[] rows = new MyTestClass[num];
for (int i = 0; i < num; i++) {
MyTestClass t = new MyTestClass();
ExtraTypeInfo extraTypeInfo = new ExtraTypeInfo();
t.randomFill(r, extraTypeInfo);
rows[i] = t;
}
StructObjectInspector rowOI = (StructObjectInspector) ObjectInspectorFactory.getReflectionObjectInspector(MyTestClass.class, ObjectInspectorOptions.JAVA);
String fieldNames = ObjectInspectorUtils.getFieldNames(rowOI);
String fieldTypes = ObjectInspectorUtils.getFieldTypes(rowOI);
Properties schema = new Properties();
schema.setProperty(serdeConstants.LIST_COLUMNS, fieldNames);
schema.setProperty(serdeConstants.LIST_COLUMN_TYPES, fieldTypes);
LazyBinarySerDe serDe = new LazyBinarySerDe();
serDe.initialize(new Configuration(), schema, null);
deserializeAndSerializeLazyBinary(serDe, rows, rowOI);
System.out.println("test: testLazyBinarySerDe - OK");
} catch (Throwable e) {
e.printStackTrace();
throw e;
}
}
Aggregations