Search in sources :

Example 1 with AbstractPrimitiveLazyObjectInspector

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));
}
Also used : ByteArrayRef(org.apache.hadoop.hive.serde2.lazy.ByteArrayRef) LazyBinary(org.apache.hadoop.hive.serde2.lazy.LazyBinary) Test(org.junit.Test)

Aggregations

ByteArrayRef (org.apache.hadoop.hive.serde2.lazy.ByteArrayRef)1 LazyBinary (org.apache.hadoop.hive.serde2.lazy.LazyBinary)1 Test (org.junit.Test)1