use of org.apache.hadoop.hive.serde2.lazy.LazyFactory.createLazyObject in project hive by apache.
the class HBaseStructValue 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}
*/
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;
}
use of org.apache.hadoop.hive.serde2.lazy.LazyFactory.createLazyObject 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;
}
use of org.apache.hadoop.hive.serde2.lazy.LazyFactory.createLazyObject in project hive by apache.
the class AccumuloCompositeRowId 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}
*/
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;
}
use of org.apache.hadoop.hive.serde2.lazy.LazyFactory.createLazyObject in project hive by apache.
the class AvroLazyObjectInspector method toLazyPrimitiveObject.
/**
* Convert the given object to a lazy object using the given {@link ObjectInspector}
*
* @param obj Object to be converted to a {@link LazyObject}
* @param oi ObjectInspector used for the conversion
* @return the created {@link LazyObject lazy object}
*/
private LazyObject<? extends ObjectInspector> toLazyPrimitiveObject(Object obj, ObjectInspector oi) {
if (obj == null) {
return null;
}
LazyObject<? extends ObjectInspector> lazyObject = LazyFactory.createLazyObject(oi);
ByteArrayRef ref = new ByteArrayRef();
String objAsString = obj.toString().trim();
ref.setData(objAsString.getBytes());
// initialize the lazy object
lazyObject.init(ref, 0, ref.getData().length);
return lazyObject;
}
use of org.apache.hadoop.hive.serde2.lazy.LazyFactory.createLazyObject in project hive by apache.
the class AvroLazyObjectInspector method toLazyListObject.
/**
* Convert the given object to a lazy object using the given {@link ObjectInspector}
*
* @param obj Object to be converted to a {@link LazyObject}
* @param oi ObjectInspector used for the conversion
* @return the created {@link LazyObject lazy object}
*/
private Object toLazyListObject(Object obj, ObjectInspector objectInspector) {
if (obj == null) {
return null;
}
List<?> listObj = (List<?>) obj;
LazyArray retList = (LazyArray) LazyFactory.createLazyObject(objectInspector);
List<Object> lazyList = retList.getList();
ObjectInspector listElementOI = ((ListObjectInspector) objectInspector).getListElementObjectInspector();
for (int i = 0; i < listObj.size(); i++) {
lazyList.add(toLazyObject(listObj.get(i), listElementOI));
}
return retList;
}
Aggregations