use of org.apache.hadoop.hive.serde2.lazy.objectinspector.primitive.AbstractPrimitiveLazyObjectInspector in project hive by apache.
the class TestLazyBinarySerDe method testLazyBinaryObjectInspector.
/**
* Test to see if byte[] with correct contents is generated by
* LazyBinaryObjectInspector from input BytesWritable
* @throws Throwable
*/
@Test
public void testLazyBinaryObjectInspector() throws Throwable {
// create input ByteArrayRef
ByteArrayRef inpBARef = new ByteArrayRef();
inpBARef.setData(inpBArray);
AbstractPrimitiveLazyObjectInspector<?> binInspector = LazyPrimitiveObjectInspectorFactory.getLazyObjectInspector(TypeInfoFactory.binaryTypeInfo, false, (byte) 0);
// create LazyBinary initialed with inputBA
LazyBinary lazyBin = (LazyBinary) LazyFactory.createLazyObject(binInspector);
lazyBin.init(inpBARef, 0, inpBArray.length);
// use inspector to get a byte[] out of LazyBinary
byte[] outBARef = (byte[]) binInspector.getPrimitiveJavaObject(lazyBin);
assertTrue("compare input and output BAs", Arrays.equals(inpBArray, outBARef));
}
Aggregations