private void initEntry(int logicalColumnIndex, int projectionColumnNum, TypeInfo typeInfo) { projectionColumnNums[logicalColumnIndex] = projectionColumnNum; typeInfos[logicalColumnIndex] = typeInfo; objectInspectors[logicalColumnIndex] = TypeInfoUtils.getStandardJavaObjectInspectorFromTypeInfo(typeInfo); }
private Object getTypeAppropriateValueFor(PrimitiveTypeInfo type, String value) { ObjectInspectorConverters.Converter converter = ObjectInspectorConverters.getConverter( TypeInfoUtils.getStandardJavaObjectInspectorFromTypeInfo(TypeInfoFactory.stringTypeInfo), TypeInfoUtils.getStandardJavaObjectInspectorFromTypeInfo(type)); return converter.convert(value); }
@Override public ConstantObjectInspector getWritableObjectInspector() { return ObjectInspectorUtils.getConstantObjectInspector( TypeInfoUtils.getStandardJavaObjectInspectorFromTypeInfo(typeInfo), value); }
@Override public ConstantObjectInspector getWritableObjectInspector() { return ObjectInspectorUtils.getConstantObjectInspector( TypeInfoUtils.getStandardJavaObjectInspectorFromTypeInfo(typeInfo), value); }
private static int computeExpected(List<String> hiveTypeStrings, List<Object> hiveValues, int bucketCount, List<TypeInfo> hiveTypeInfos) throws HiveException { ImmutableList.Builder<Entry<ObjectInspector, Object>> columnBindingsBuilder = ImmutableList.builder(); for (int i = 0; i < hiveTypeStrings.size(); i++) { Object javaValue = hiveValues.get(i); columnBindingsBuilder.add(Maps.immutableEntry( TypeInfoUtils.getStandardJavaObjectInspectorFromTypeInfo(hiveTypeInfos.get(i)), javaValue)); } return getHiveBucket(columnBindingsBuilder.build(), bucketCount); }
/** * Converts the skewedValue available as a string in the metadata to the appropriate object * by using the type of the column from the join key. * @param skewedValue * @param keyCol * @return an expression node descriptor of the appropriate constant */ private ExprNodeConstantDesc createConstDesc( String skewedValue, ExprNodeColumnDesc keyCol) { ObjectInspector inputOI = TypeInfoUtils.getStandardJavaObjectInspectorFromTypeInfo( TypeInfoFactory.stringTypeInfo); ObjectInspector outputOI = TypeInfoUtils.getStandardJavaObjectInspectorFromTypeInfo( keyCol.getTypeInfo()); Converter converter = ObjectInspectorConverters.getConverter(inputOI, outputOI); Object skewedValueObject = converter.convert(skewedValue); return new ExprNodeConstantDesc(keyCol.getTypeInfo(), skewedValueObject); }
/** * Converts the skewedValue available as a string in the metadata to the appropriate object * by using the type of the column from the join key. * @param skewedValue * @param keyCol * @return an expression node descriptor of the appropriate constant */ private ExprNodeConstantDesc createConstDesc( String skewedValue, ExprNodeColumnDesc keyCol) { ObjectInspector inputOI = TypeInfoUtils.getStandardJavaObjectInspectorFromTypeInfo( TypeInfoFactory.stringTypeInfo); ObjectInspector outputOI = TypeInfoUtils.getStandardJavaObjectInspectorFromTypeInfo( keyCol.getTypeInfo()); Converter converter = ObjectInspectorConverters.getConverter(inputOI, outputOI); Object skewedValueObject = converter.convert(skewedValue); return new ExprNodeConstantDesc(keyCol.getTypeInfo(), skewedValueObject); }
@Override public GenericUDAFEvaluator getEvaluator(TypeInfo[] parameters) throws SemanticException { if (parameters.length != 1) { throw new UDFArgumentTypeException(parameters.length - 1, "Exactly one argument is expected."); } ObjectInspector oi = TypeInfoUtils.getStandardJavaObjectInspectorFromTypeInfo(parameters[0]); if (!ObjectInspectorUtils.compareSupported(oi)) { throw new UDFArgumentTypeException(parameters.length - 1, "Cannot support comparison of map<> type or complex type containing map<>."); } return new GenericUDAFMaxEvaluator(); }
@Override public GenericUDAFEvaluator getEvaluator(TypeInfo[] parameters) throws SemanticException { if (parameters.length != 1) { throw new UDFArgumentTypeException(parameters.length - 1, "Exactly one argument is expected."); } ObjectInspector oi = TypeInfoUtils.getStandardJavaObjectInspectorFromTypeInfo(parameters[0]); boolean c = ObjectInspectorUtils.compareTypes(oi, PrimitiveObjectInspectorFactory.writableIntObjectInspector); if (!c) { throw new UDFArgumentTypeException(0, "Number of tiles must be an int expression"); } return new GenericUDAFNTileEvaluator(); }
@Override public GenericUDAFEvaluator getEvaluator(TypeInfo[] parameters) throws SemanticException { if (parameters.length != 1) { throw new UDFArgumentTypeException(parameters.length - 1, "Exactly one argument is expected."); } ObjectInspector oi = TypeInfoUtils.getStandardJavaObjectInspectorFromTypeInfo(parameters[0]); if (!ObjectInspectorUtils.compareSupported(oi)) { throw new UDFArgumentTypeException(parameters.length - 1, "Cannot support comparison of map<> type or complex type containing map<>."); } return new GenericUDAFMinEvaluator(); }
@Override public GenericUDAFEvaluator getEvaluator(TypeInfo[] parameters) throws SemanticException { if (parameters.length < 1) { throw new UDFArgumentTypeException(parameters.length - 1, "One or more arguments are expected."); } for (int i = 0; i < parameters.length; i++) { ObjectInspector oi = TypeInfoUtils.getStandardJavaObjectInspectorFromTypeInfo(parameters[i]); if (!ObjectInspectorUtils.compareSupported(oi)) { throw new UDFArgumentTypeException(i, "Cannot support comparison of map<> type or complex type containing map<>."); } } return createEvaluator(); }
public static void getPartitionValues(VectorizedRowBatchCtx vrbCtx, PartitionDesc partDesc, Object[] partitionValues) { LinkedHashMap<String, String> partSpec = partDesc.getPartSpec(); for (int i = 0; i < vrbCtx.partitionColumnCount; i++) { Object objectValue; if (partSpec == null) { // For partition-less table, initialize partValue to empty string. // We can have partition-less table even if we have partition keys // when there is only only partition selected and the partition key is not // part of the projection/include list. objectValue = null; } else { String key = vrbCtx.rowColumnNames[vrbCtx.dataColumnCount + i]; // Create a Standard java object Inspector TypeInfo partColTypeInfo = vrbCtx.rowColumnTypeInfos[vrbCtx.dataColumnCount + i]; ObjectInspector objectInspector = TypeInfoUtils.getStandardJavaObjectInspectorFromTypeInfo(partColTypeInfo); objectValue = ObjectInspectorConverters. getConverter(PrimitiveObjectInspectorFactory. javaStringObjectInspector, objectInspector). convert(partSpec.get(key)); if (partColTypeInfo instanceof CharTypeInfo) { objectValue = ((HiveChar) objectValue).getStrippedValue(); } } partitionValues[i] = objectValue; } }
@Override public GenericUDAFEvaluator getEvaluator(TypeInfo[] parameters) throws SemanticException { if (parameters.length != 1) { throw new UDFArgumentTypeException(parameters.length - 1, "Exactly one argument is expected."); } ObjectInspector oi = TypeInfoUtils.getStandardJavaObjectInspectorFromTypeInfo(parameters[0]); if (!ObjectInspectorUtils.compareSupported(oi)) { throw new UDFArgumentTypeException(parameters.length - 1, "Cannot support comparison of map<> type or complex type containing map<>."); } return new GenericUDAFMaxEvaluator(); }
@Override public GenericUDAFEvaluator getEvaluator(TypeInfo[] parameters) throws SemanticException { if (parameters.length != 1) { throw new UDFArgumentTypeException(parameters.length - 1, "Exactly one argument is expected."); } ObjectInspector oi = TypeInfoUtils.getStandardJavaObjectInspectorFromTypeInfo(parameters[0]); if (!ObjectInspectorUtils.compareSupported(oi)) { throw new UDFArgumentTypeException(parameters.length - 1, "Cannot support comparison of map<> type or complex type containing map<>."); } return new GenericUDAFEWAHBitmapEvaluator(); }
@Override public GenericUDAFEvaluator getEvaluator(TypeInfo[] parameters) throws SemanticException { if (parameters.length != 1) { throw new UDFArgumentTypeException(parameters.length - 1, "Exactly one argument is expected."); } ObjectInspector oi = TypeInfoUtils.getStandardJavaObjectInspectorFromTypeInfo(parameters[0]); boolean c = ObjectInspectorUtils.compareTypes(oi, PrimitiveObjectInspectorFactory.writableIntObjectInspector); if (!c) { throw new UDFArgumentTypeException(0, "Number of tiles must be an int expression"); } return new GenericUDAFNTileEvaluator(); }
@Override public GenericUDAFEvaluator getEvaluator(TypeInfo[] parameters) throws SemanticException { if (parameters.length != 1) { throw new UDFArgumentTypeException(parameters.length - 1, "Exactly one argument is expected."); } ObjectInspector oi = TypeInfoUtils.getStandardJavaObjectInspectorFromTypeInfo(parameters[0]); if (!ObjectInspectorUtils.compareSupported(oi)) { throw new UDFArgumentTypeException(parameters.length - 1, "Cannot support comparison of map<> type or complex type containing map<>."); } return new GenericUDAFMinEvaluator(); }
@Override public GenericUDAFEvaluator getEvaluator(TypeInfo[] parameters) throws SemanticException { if (parameters.length < 1) { throw new UDFArgumentTypeException(parameters.length - 1, "One or more arguments are expected."); } for (int i = 0; i < parameters.length; i++) { ObjectInspector oi = TypeInfoUtils.getStandardJavaObjectInspectorFromTypeInfo(parameters[i]); if (!ObjectInspectorUtils.compareSupported(oi)) { throw new UDFArgumentTypeException(i, "Cannot support comparison of map<> type or complex type containing map<>."); } } return createEvaluator(); }
/** * gets values for fields requested by output schema which will not be in the data */ private static Map<String, Object> getColValsNotInDataColumns(HCatSchema outputSchema, PartInfo partInfo) throws HCatException { HCatSchema dataSchema = partInfo.getPartitionSchema(); Map<String, Object> vals = new HashMap<String, Object>(); for (String fieldName : outputSchema.getFieldNames()) { if (dataSchema.getPosition(fieldName) == null) { // this entry of output is not present in the output schema // so, we first check the table schema to see if it is a part col if (partInfo.getPartitionValues().containsKey(fieldName)) { // First, get the appropriate field schema for this field HCatFieldSchema fschema = outputSchema.get(fieldName); // For a partition key type, this will be a primitive typeinfo. // Obtain relevant object inspector for this typeinfo ObjectInspector oi = TypeInfoUtils.getStandardJavaObjectInspectorFromTypeInfo(fschema.getTypeInfo()); // get appropriate object from the string representation of the value in partInfo.getPartitionValues() // Essentially, partition values are represented as strings, but we want the actual object type associated Object objVal = ObjectInspectorConverters .getConverter(PrimitiveObjectInspectorFactory.javaStringObjectInspector, oi) .convert(partInfo.getPartitionValues().get(fieldName)); vals.put(fieldName, objVal); } else { vals.put(fieldName, null); } } } return vals; }
public static void getPartitionValues(VectorizedRowBatchCtx vrbCtx, PartitionDesc partDesc, Object[] partitionValues) { LinkedHashMap<String, String> partSpec = partDesc.getPartSpec(); for (int i = 0; i < vrbCtx.partitionColumnCount; i++) { Object objectValue; if (partSpec == null) { // For partition-less table, initialize partValue to empty string. // We can have partition-less table even if we have partition keys // when there is only only partition selected and the partition key is not // part of the projection/include list. objectValue = null; } else { String key = vrbCtx.rowColumnNames[vrbCtx.dataColumnCount + i]; // Create a Standard java object Inspector TypeInfo partColTypeInfo = vrbCtx.rowColumnTypeInfos[vrbCtx.dataColumnCount + i]; ObjectInspector objectInspector = TypeInfoUtils.getStandardJavaObjectInspectorFromTypeInfo(partColTypeInfo); objectValue = ObjectInspectorConverters. getConverter(PrimitiveObjectInspectorFactory. javaStringObjectInspector, objectInspector). convert(partSpec.get(key)); if (partColTypeInfo instanceof CharTypeInfo) { objectValue = ((HiveChar) objectValue).getStrippedValue(); } } partitionValues[i] = objectValue; } }
field.isPrimitive = false; field.objectInspector = TypeInfoUtils.getStandardJavaObjectInspectorFromTypeInfo(typeInfo); switch (category) { case LIST: