use of org.apache.hadoop.hive.serde2.objectinspector.StructObjectInspector in project hive by apache.
the class VectorExtractRow method init.
/*
* Initialize using an StructObjectInspector and a column projection list.
*/
public void init(StructObjectInspector structObjectInspector, List<Integer> projectedColumns) throws HiveException {
List<? extends StructField> fields = structObjectInspector.getAllStructFieldRefs();
final int count = fields.size();
allocateArrays(count);
for (int i = 0; i < count; i++) {
int projectionColumnNum = projectedColumns.get(i);
StructField field = fields.get(i);
ObjectInspector fieldInspector = field.getFieldObjectInspector();
TypeInfo typeInfo = TypeInfoUtils.getTypeInfoFromTypeString(fieldInspector.getTypeName());
initEntry(i, projectionColumnNum, typeInfo);
}
}
use of org.apache.hadoop.hive.serde2.objectinspector.StructObjectInspector in project hive by apache.
the class VectorizedBatchUtil method columnNamesFromStructObjectInspector.
public static String[] columnNamesFromStructObjectInspector(StructObjectInspector structObjectInspector) throws HiveException {
List<? extends StructField> fields = structObjectInspector.getAllStructFieldRefs();
String[] result = new String[fields.size()];
int i = 0;
for (StructField field : fields) {
result[i++] = field.getFieldName();
}
return result;
}
use of org.apache.hadoop.hive.serde2.objectinspector.StructObjectInspector in project hive by apache.
the class VectorAssignRow method init.
/*
* Initialize using an StructObjectInspector.
* No projection -- the column range 0 .. fields.size()-1
*/
public void init(StructObjectInspector structObjectInspector) throws HiveException {
List<? extends StructField> fields = structObjectInspector.getAllStructFieldRefs();
final int count = fields.size();
allocateArrays(count);
for (int i = 0; i < count; i++) {
StructField field = fields.get(i);
ObjectInspector fieldInspector = field.getFieldObjectInspector();
TypeInfo typeInfo = TypeInfoUtils.getTypeInfoFromTypeString(fieldInspector.getTypeName());
initTargetEntry(i, i, typeInfo);
}
}
use of org.apache.hadoop.hive.serde2.objectinspector.StructObjectInspector in project hive by apache.
the class PTFDeserializer method addInputColumnsToList.
private static void addInputColumnsToList(ShapeDetails shape, ArrayList<String> fieldNames, ArrayList<ObjectInspector> fieldOIs) {
StructObjectInspector OI = shape.getOI();
for (StructField f : OI.getAllStructFieldRefs()) {
fieldNames.add(f.getFieldName());
fieldOIs.add(f.getFieldObjectInspector());
}
}
use of org.apache.hadoop.hive.serde2.objectinspector.StructObjectInspector in project hive by apache.
the class PTFDeserializer method initialize.
protected void initialize(ShapeDetails shp, StructObjectInspector OI) throws HiveException {
String serdeClassName = shp.getSerdeClassName();
Properties serDeProps = new Properties();
Map<String, String> serdePropsMap = new LinkedHashMap<String, String>();
addOIPropertiestoSerDePropsMap(OI, serdePropsMap);
for (String serdeName : serdePropsMap.keySet()) {
serDeProps.setProperty(serdeName, serdePropsMap.get(serdeName));
}
try {
AbstractSerDe serDe = ReflectionUtils.newInstance(hConf.getClassByName(serdeClassName).asSubclass(AbstractSerDe.class), hConf);
SerDeUtils.initializeSerDe(serDe, hConf, serDeProps, null);
shp.setSerde(serDe);
StructObjectInspector outOI = PTFPartition.setupPartitionOutputOI(serDe, OI);
shp.setOI(outOI);
} catch (Exception se) {
throw new HiveException(se);
}
}
Aggregations