Refine search
@Override public StructObjectInspector initialize(ObjectInspector[] argOIs) throws UDFArgumentException { ArrayList<String> fieldNames = new ArrayList<String>(); ArrayList<ObjectInspector> fieldOIs = new ArrayList<ObjectInspector>(); fieldNames.add("col1"); fieldOIs.add(PrimitiveObjectInspectorFactory.javaIntObjectInspector); return ObjectInspectorFactory.getStandardStructObjectInspector(fieldNames, fieldOIs); }
private void initPartialResultInspector() { List<ObjectInspector> foi = new ArrayList<ObjectInspector>(); foi.add(PrimitiveObjectInspectorFactory.writableLongObjectInspector); foi.add(PrimitiveObjectInspectorFactory.writableDoubleObjectInspector); List<String> fname = new ArrayList<String>(); fname.add("count"); fname.add("sum"); soi = ObjectInspectorFactory.getStandardStructObjectInspector(fname, foi); }
private ObjectInspector createObjectInspector() throws SerDeException { List<ObjectInspector> columnOIs = new ArrayList<ObjectInspector>(columnNames.size()); // At this point we've verified the types are correct. for(int i = 0; i < columnNames.size(); i++) { columnOIs.add(i, createObjectInspectorWorker(columnTypes.get(i))); } return ObjectInspectorFactory.getStandardStructObjectInspector(columnNames, columnOIs, columnComments); }
List<TypeInfo> columnTypes = TypeInfoUtils .getTypeInfosFromTypeString(columnTypeProperty); assert columnNames.size() == columnTypes.size(); numColumns = columnNames.size(); columnNames.size()); for (int c = 0; c < numColumns; c++) { columnOIs.add(PrimitiveObjectInspectorFactory.javaStringObjectInspector); rowOI = ObjectInspectorFactory.getStandardStructObjectInspector( columnNames, columnOIs); row.add(null);
sois.addAll(Arrays.asList(fieldObjectInspectors)); if (outputColNames.size() > length) { int numExprs = 0; for (int i : distinctCols) { names.add(HiveConf.getColumnInternalName(numExprs)); eois.add(evals[i].initialize(rowInspector)); numExprs++; uois.add(ObjectInspectorFactory.getStandardStructObjectInspector(names, eois)); sois.add(uoi); return ObjectInspectorFactory.getStandardStructObjectInspector(outputColNames, sois );
public StructObjectInspector partialRowStructObjectInspector(int partialFieldCount) { ArrayList<ObjectInspector> partialObjectInspectorList = new ArrayList<ObjectInspector>(partialFieldCount); List<String> columnNames = new ArrayList<String>(partialFieldCount); for (int i = 0; i < partialFieldCount; i++) { columnNames.add(String.format("partial%d", i)); partialObjectInspectorList.add(getObjectInspector(typeInfos[i])); } return ObjectInspectorFactory.getStandardStructObjectInspector( columnNames, objectInspectorList); }
checkNotNull(arguments, "arguments"); checkNotNull(bodyDesc, "bodyDesc"); if(colTypes.size() != arguments.length) { throw new UDFArgumentLengthException( "The macro " + macroName + " accepts exactly " + colTypes.size() + " arguments."); ArrayList<ObjectInspector> colObjectInspectors = new ArrayList<ObjectInspector>(colTypes.size()); for (int index = 0; index < arguments.length; ++index) { ObjectInspector objectInspector = TypeInfoUtils. getStandardWritableObjectInspectorFromTypeInfo(colTypes.get(index)); colObjectInspectors.add(objectInspector); converters[index] = ObjectInspectorConverters.getConverter(arguments[index], objectInspector); .getStandardStructObjectInspector(colNames, colObjectInspectors); try { return body.initialize(structOI);
.collect(toList()); fieldCount = fileColumnNames.size(); tableInspector = getStandardStructObjectInspector(fileColumnNames, objectInspectors); setters = new FieldSetter[structFields.size()]; for (int i = 0; i < setters.length; i++) { setters[i] = createFieldSetter(tableInspector, row, structFields.get(i), fileColumnTypes.get(structFields.get(i).getFieldID()));
columnNames.addAll(MetadataColumn.KAFKA_METADATA_COLUMN_NAMES); final List<ObjectInspector> inspectors = new ArrayList<>(columnNames.size()); inspectors.addAll(delegateDeserializerOI.getAllStructFieldRefs() .stream() .collect(Collectors.toList())); inspectors.addAll(MetadataColumn.KAFKA_METADATA_INSPECTORS); objectInspector = ObjectInspectorFactory.getStandardStructObjectInspector(columnNames, inspectors); metadataStartIndex = columnNames.size() - MetadataColumn.values().length;
protected static StructObjectInspector createSelectListOI(MatchPath evaluator, PTFInputDef inpDef) { StructObjectInspector inOI = inpDef.getOutputShape().getOI(); ArrayList<String> inputColumnNames = new ArrayList<String>(); ArrayList<String> selectListNames = new ArrayList<String>(); ArrayList<ObjectInspector> fieldOIs = new ArrayList<ObjectInspector>(); for(StructField f : inOI.getAllStructFieldRefs()) { String inputColName = evaluator.inputColumnNamesMap.get(f.getFieldName()); if ( inputColName != null ) { inputColumnNames.add(inputColName); selectListNames.add(f.getFieldName()); fieldOIs.add(f.getFieldObjectInspector()); } } StandardListObjectInspector pathAttrOI = ObjectInspectorFactory.getStandardListObjectInspector( ObjectInspectorFactory.getStandardStructObjectInspector(inputColumnNames, fieldOIs)); ArrayList<ObjectInspector> selectFieldOIs = new ArrayList<ObjectInspector>(); selectFieldOIs.addAll(fieldOIs); selectFieldOIs.add(pathAttrOI); selectListNames.add(MatchPath.PATHATTR_NAME); return ObjectInspectorFactory.getStandardStructObjectInspector( selectListNames, selectFieldOIs); }
public static StructObjectInspector getVCSObjectInspector(List<VirtualColumn> vcs) { List<String> names = new ArrayList<String>(vcs.size()); List<ObjectInspector> inspectors = new ArrayList<ObjectInspector>(vcs.size()); for (VirtualColumn vc : vcs) { names.add(vc.getName()); inspectors.add(vc.oi); } return ObjectInspectorFactory.getStandardStructObjectInspector(names, inspectors); }
private void initPartialResultInspector() { List<ObjectInspector> foi = new ArrayList<ObjectInspector>(); foi.add(PrimitiveObjectInspectorFactory.writableLongObjectInspector); foi.add(PrimitiveObjectInspectorFactory.writableDoubleObjectInspector); List<String> fname = new ArrayList<String>(); fname.add("count"); fname.add("sum"); soi = ObjectInspectorFactory.getStandardStructObjectInspector(fname, foi); }
assert columnNames.size() == columnTypes.size(); numCols = columnNames.size(); + " has category " + columnTypes.get(i).getCategory()); columnOIs.add(TypeInfoUtils.getStandardWritableObjectInspectorFromTypeInfo(columnTypes.get(i))); rowOI = ObjectInspectorFactory.getStandardStructObjectInspector(columnNames, columnOIs); row.add(null);
sois.addAll(Arrays.asList(fieldObjectInspectors)); if (outputColNames.size() > length) { int numExprs = 0; for (int i : distinctCols) { names.add(HiveConf.getColumnInternalName(numExprs)); eois.add(evals[i].initialize(rowInspector)); numExprs++; uois.add(ObjectInspectorFactory.getStandardStructObjectInspector(names, eois)); sois.add(uoi); return ObjectInspectorFactory.getStandardStructObjectInspector(outputColNames, sois );
public static StandardStructObjectInspector convertToStandardStructObjectInspector( StructObjectInspector structObjectInspector) throws HiveException { List<? extends StructField> fields = structObjectInspector.getAllStructFieldRefs(); List<ObjectInspector> oids = new ArrayList<ObjectInspector>(); ArrayList<String> columnNames = new ArrayList<String>(); for(StructField field : fields) { TypeInfo typeInfo = TypeInfoUtils.getTypeInfoFromTypeString( field.getFieldObjectInspector().getTypeName()); ObjectInspector standardWritableObjectInspector = TypeInfoUtils.getStandardWritableObjectInspectorFromTypeInfo(typeInfo); oids.add(standardWritableObjectInspector); columnNames.add(field.getFieldName()); } return ObjectInspectorFactory.getStandardStructObjectInspector(columnNames,oids); }
checkNotNull(arguments, "arguments"); checkNotNull(bodyDesc, "bodyDesc"); if(colTypes.size() != arguments.length) { throw new UDFArgumentLengthException( "The macro " + macroName + " accepts exactly " + colTypes.size() + " arguments."); ArrayList<ObjectInspector> colObjectInspectors = new ArrayList<ObjectInspector>(colTypes.size()); for (int index = 0; index < arguments.length; ++index) { ObjectInspector objectInspector = TypeInfoUtils. getStandardWritableObjectInspectorFromTypeInfo(colTypes.get(index)); colObjectInspectors.add(objectInspector); converters[index] = ObjectInspectorConverters.getConverter(arguments[index], objectInspector); .getStandardStructObjectInspector(colNames, colObjectInspectors); try { return body.initialize(structOI);
/** * returns the InspectableObject array the builder methods * helped to assemble. * @return InspectableObject array (objects that have data coupled with * and object inspector ) */ public InspectableObject[] createRows(){ InspectableObject[] toReturn = new InspectableObject[this.rows.size()]; for (int i=0; i<toReturn.length;i++){ toReturn[i] = new InspectableObject(); toReturn[i].o = rows.get(i); toReturn[i].oi = ObjectInspectorFactory.getStandardStructObjectInspector( this.columnNames, this.columnTypes); } return toReturn; } }
/** * Create a new struct object inspector for the list of struct fields, first removing the * prefix from the field name. * @param fields * @param prefixToRemove * @return */ private static ObjectInspector createStructFromFields(List<StructField> fields, String prefixToRemove) { int prefixLength = prefixToRemove.length() + 1; // also remove the '.' after the prefix ArrayList<String> fieldNames = new ArrayList<String>(); ArrayList<ObjectInspector> fieldOIs = new ArrayList<ObjectInspector>(); for (StructField field : fields) { fieldNames.add(field.getFieldName().substring(prefixLength)); fieldOIs.add(field.getFieldObjectInspector()); } return ObjectInspectorFactory.getStandardStructObjectInspector(fieldNames, fieldOIs); }
protected static StructObjectInspector createSelectListOI(MatchPath evaluator, PTFInputDef inpDef) { StructObjectInspector inOI = inpDef.getOutputShape().getOI(); ArrayList<String> inputColumnNames = new ArrayList<String>(); ArrayList<String> selectListNames = new ArrayList<String>(); ArrayList<ObjectInspector> fieldOIs = new ArrayList<ObjectInspector>(); for(StructField f : inOI.getAllStructFieldRefs()) { String inputColName = evaluator.inputColumnNamesMap.get(f.getFieldName()); if ( inputColName != null ) { inputColumnNames.add(inputColName); selectListNames.add(f.getFieldName()); fieldOIs.add(f.getFieldObjectInspector()); } } StandardListObjectInspector pathAttrOI = ObjectInspectorFactory.getStandardListObjectInspector( ObjectInspectorFactory.getStandardStructObjectInspector(inputColumnNames, fieldOIs)); ArrayList<ObjectInspector> selectFieldOIs = new ArrayList<ObjectInspector>(); selectFieldOIs.addAll(fieldOIs); selectFieldOIs.add(pathAttrOI); selectListNames.add(MatchPath.PATHATTR_NAME); return ObjectInspectorFactory.getStandardStructObjectInspector( selectListNames, selectFieldOIs); }
public static StructObjectInspector getVCSObjectInspector(List<VirtualColumn> vcs) { List<String> names = new ArrayList<String>(vcs.size()); List<ObjectInspector> inspectors = new ArrayList<ObjectInspector>(vcs.size()); for (VirtualColumn vc : vcs) { names.add(vc.getName()); inspectors.add(vc.oi); } return ObjectInspectorFactory.getStandardStructObjectInspector(names, inspectors); }