Search in sources :

Example 16 with LazyObject

use of org.apache.hadoop.hive.serde2.lazy.LazyObject in project hive by apache.

the class HBaseTestStructSerializer method toLazyObject.

/**
 * Create an initialize a {@link LazyObject} with the given bytes for the given fieldID.
 *
 * @param fieldID field for which the object is to be created
 * @param bytes value with which the object is to be initialized with
 *
 * @return initialized {@link LazyObject}
 */
@Override
public LazyObject<? extends ObjectInspector> toLazyObject(int fieldID, byte[] bytes) {
    ObjectInspector fieldOI = oi.getAllStructFieldRefs().get(fieldID).getFieldObjectInspector();
    LazyObject<? extends ObjectInspector> lazyObject = LazyFactory.createLazyObject(fieldOI);
    ByteArrayRef ref = new ByteArrayRef();
    ref.setData(bytes);
    // initialize the lazy object
    lazyObject.init(ref, 0, ref.getData().length);
    return lazyObject;
}
Also used : LazySimpleStructObjectInspector(org.apache.hadoop.hive.serde2.lazy.objectinspector.LazySimpleStructObjectInspector) ObjectInspector(org.apache.hadoop.hive.serde2.objectinspector.ObjectInspector) ByteArrayRef(org.apache.hadoop.hive.serde2.lazy.ByteArrayRef)

Aggregations

ByteArrayRef (org.apache.hadoop.hive.serde2.lazy.ByteArrayRef)9 LazySimpleStructObjectInspector (org.apache.hadoop.hive.serde2.lazy.objectinspector.LazySimpleStructObjectInspector)8 ObjectInspector (org.apache.hadoop.hive.serde2.objectinspector.ObjectInspector)8 LazyObject (org.apache.hadoop.hive.serde2.lazy.LazyObject)7 LazyMapObjectInspector (org.apache.hadoop.hive.serde2.lazy.objectinspector.LazyMapObjectInspector)6 Map (java.util.Map)4 LazyListObjectInspector (org.apache.hadoop.hive.serde2.lazy.objectinspector.LazyListObjectInspector)4 LazyUnionObjectInspector (org.apache.hadoop.hive.serde2.lazy.objectinspector.LazyUnionObjectInspector)4 ArrayList (java.util.ArrayList)3 LazyMap (org.apache.hadoop.hive.serde2.lazy.LazyMap)3 ListObjectInspector (org.apache.hadoop.hive.serde2.objectinspector.ListObjectInspector)3 MapObjectInspector (org.apache.hadoop.hive.serde2.objectinspector.MapObjectInspector)3 LinkedHashMap (java.util.LinkedHashMap)2 List (java.util.List)2 LazyPrimitive (org.apache.hadoop.hive.serde2.lazy.LazyPrimitive)2 ListTypeInfo (org.apache.hadoop.hive.serde2.typeinfo.ListTypeInfo)2 MapTypeInfo (org.apache.hadoop.hive.serde2.typeinfo.MapTypeInfo)2 PrimitiveTypeInfo (org.apache.hadoop.hive.serde2.typeinfo.PrimitiveTypeInfo)2 StructTypeInfo (org.apache.hadoop.hive.serde2.typeinfo.StructTypeInfo)2 UnionTypeInfo (org.apache.hadoop.hive.serde2.typeinfo.UnionTypeInfo)2