use of org.apache.hadoop.hive.serde2.lazy.objectinspector.LazyUnionObjectInspector in project hive by apache.
the class AvroLazyObjectInspector method toLazyUnionObject.
/**
* 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 toLazyUnionObject(Object obj, ObjectInspector objectInspector) {
if (obj == null) {
return null;
}
if (!(objectInspector instanceof LazyUnionObjectInspector)) {
throw new IllegalArgumentException("Invalid objectinspector found. Expected LazyUnionObjectInspector, Found " + objectInspector.getClass());
}
StandardUnion standardUnion = (StandardUnion) obj;
LazyUnionObjectInspector lazyUnionOI = (LazyUnionObjectInspector) objectInspector;
// Grab the tag and the field
byte tag = standardUnion.getTag();
Object field = standardUnion.getObject();
ObjectInspector fieldOI = lazyUnionOI.getObjectInspectors().get(tag);
// convert to lazy object
Object convertedObj = null;
if (field != null) {
convertedObj = toLazyObject(field, fieldOI);
}
if (convertedObj == null) {
return null;
}
return new LazyUnion(lazyUnionOI, tag, convertedObj);
}
Aggregations