TypeInfo ti2 = TypeInfoUtils.getTypeInfoFromTypeString(cat2); try { commonClass = FunctionRegistry.getCommonClassForComparison(ti1, ti2);
private void comparison(TypeInfo a, TypeInfo b, TypeInfo result) { assertEquals(result, FunctionRegistry.getCommonClassForComparison(a,b)); }
public static TypeInfo deriveInType(List<ExprNodeDesc> children) { TypeInfo returnType = null; for (ExprNodeDesc node : children) { TypeInfo ti = node.getTypeInfo(); if (ti.getCategory() == Category.PRIMITIVE && ((PrimitiveTypeInfo)ti).getPrimitiveCategory() == PrimitiveCategory.VOID) { continue; } if (returnType == null) { returnType = ti; continue; } if (returnType == ti) continue; TypeInfo commonTypeInfo = FunctionRegistry.getCommonClassForComparison(returnType, ti); if (commonTypeInfo == null) return null; returnType = commonTypeInfo; } return returnType; }
TypeInfo commonType = FunctionRegistry.getCommonClassForComparison(childExpr.get(1).getTypeInfo(), childExpr.get(2).getTypeInfo()); if (commonType == null) { commonType = FunctionRegistry.getCommonClassForComparison(commonType, childExpr.get(3).getTypeInfo()); if (commonType == null) {
commonType = FunctionRegistry.getCommonClassForComparison(tLeft, tRight); if (commonType == null) { commonType = returnType;
TypeInfo commonType = FunctionRegistry.getCommonClassForComparison(childExpr.get(1).getTypeInfo(), childExpr.get(2).getTypeInfo()); if (commonType == null) { commonType = FunctionRegistry.getCommonClassForComparison(commonType, childExpr.get(3).getTypeInfo()); if (commonType == null) {
commonType = FunctionRegistry.getCommonClassForComparison(tLeft, tRight); if (commonType == null) { commonType = returnType;
@Override public ObjectInspector initialize(ObjectInspector[] arguments) throws UDFArgumentException { this.objectInspectors = arguments; checkArgsSize(arguments, 4, 4); checkArgPrimitive(arguments, 0); checkArgPrimitive(arguments, 1); checkArgPrimitive(arguments, 2); checkArgPrimitive(arguments, 3); PrimitiveObjectInspector.PrimitiveCategory[] inputTypes = new PrimitiveObjectInspector.PrimitiveCategory[4]; checkArgGroups(arguments, 0, inputTypes, NUMERIC_GROUP, VOID_GROUP); checkArgGroups(arguments, 1, inputTypes, NUMERIC_GROUP, VOID_GROUP); checkArgGroups(arguments, 2, inputTypes, NUMERIC_GROUP, VOID_GROUP); checkArgGroups(arguments, 3, inputTypes, NUMERIC_GROUP, VOID_GROUP); TypeInfo exprTypeInfo = TypeInfoUtils.getTypeInfoFromObjectInspector(this.objectInspectors[0]); TypeInfo minValueTypeInfo = TypeInfoUtils.getTypeInfoFromObjectInspector(this.objectInspectors[1]); TypeInfo maxValueTypeInfo = TypeInfoUtils.getTypeInfoFromObjectInspector(this.objectInspectors[2]); TypeInfo commonExprMinMaxTypeInfo = FunctionRegistry.getCommonClassForComparison(exprTypeInfo, FunctionRegistry.getCommonClassForComparison(minValueTypeInfo, maxValueTypeInfo)); this.commonExprMinMaxOI = TypeInfoUtils.getStandardWritableObjectInspectorFromTypeInfo(commonExprMinMaxTypeInfo); this.epxrConverterOI = ObjectInspectorConverters.getConverter(this.objectInspectors[0], this.commonExprMinMaxOI); this.minValueConverterOI = ObjectInspectorConverters.getConverter(this.objectInspectors[1], this.commonExprMinMaxOI); this.maxValueConverterOI = ObjectInspectorConverters.getConverter(this.objectInspectors[2], this.commonExprMinMaxOI); return PrimitiveObjectInspectorFactory.writableIntObjectInspector; }
TypeInfo tgtType = FunctionRegistry.getCommonClassForComparison(lType, rType);
tgtDT = FunctionRegistry.getCommonClassForComparison(func.getChildren().get(0) .getTypeInfo(), func.getChildren().get(1).getTypeInfo()); } else if (isWhenCase) { tgtDT = FunctionRegistry.getCommonClassForComparison( func.getChildren().get(1).getTypeInfo(), FunctionRegistry.getCommonClassForComparison( func.getChildren().get(2).getTypeInfo(), func.getChildren().get(3).getTypeInfo())); tgtDT = FunctionRegistry.getCommonClassForComparison(func.getChildren().get(0) .getTypeInfo(), func.getChildren().get(1).getTypeInfo());
TypeInfo tgtType = FunctionRegistry.getCommonClassForComparison(lType, rType);
break; case COMPARISON: commonTypeInfo = FunctionRegistry.getCommonClassForComparison(rTypeInfo, oiTypeInfo); break;
@Override public ObjectInspector initialize(ObjectInspector[] arguments) throws UDFArgumentException { if (arguments.length < 2) { throw new UDFArgumentLengthException(getFuncName() + " requires at least 2 arguments, got " + arguments.length); } if (arguments[0].getCategory() != ObjectInspector.Category.PRIMITIVE) { throw new UDFArgumentException(getFuncName() + " only takes primitive types, got " + arguments[0].getTypeName()); } argumentOIs = arguments; converters = new Converter[arguments.length]; TypeInfo commonInfo = TypeInfoUtils.getTypeInfoFromObjectInspector(arguments[0]); for (int i = 1; i < arguments.length; i++) { PrimitiveTypeInfo currInfo = (PrimitiveTypeInfo) TypeInfoUtils.getTypeInfoFromObjectInspector(arguments[i]); commonInfo = FunctionRegistry.getCommonClassForComparison( commonInfo, currInfo); } resultOI = TypeInfoUtils.getStandardWritableObjectInspectorFromTypeInfo( (commonInfo == null) ? TypeInfoFactory.doubleTypeInfo : commonInfo); for (int i = 0; i < arguments.length; i++) { converters[i] = ObjectInspectorConverters.getConverter(arguments[i], resultOI); } return resultOI; }
TypeInfo a = commonType; TypeInfo b = keys[i][k].getTypeInfo(); commonType = FunctionRegistry.getCommonClassForComparison(a, b); if (commonType == null) { throw new SemanticException(
(type1, type2) -> getCommonClassForComparison(type1, type2));
TypeInfo a = commonType; TypeInfo b = keys[i][k].getTypeInfo(); commonType = FunctionRegistry.getCommonClassForComparison(a, b); if (commonType == null) { throw new SemanticException(
@Override public ObjectInspector initialize(ObjectInspector[] arguments) throws UDFArgumentException { if (arguments.length < 2) { throw new UDFArgumentLengthException(getFuncName() + " requires at least 2 arguments, got " + arguments.length); } if (arguments[0].getCategory() != ObjectInspector.Category.PRIMITIVE) { throw new UDFArgumentException(getFuncName() + " only takes primitive types, got " + arguments[0].getTypeName()); } argumentOIs = arguments; converters = new Converter[arguments.length]; TypeInfo commonInfo = TypeInfoUtils.getTypeInfoFromObjectInspector(arguments[0]); for (int i = 1; i < arguments.length; i++) { PrimitiveTypeInfo currInfo = (PrimitiveTypeInfo) TypeInfoUtils.getTypeInfoFromObjectInspector(arguments[i]); commonInfo = FunctionRegistry.getCommonClassForComparison( commonInfo, currInfo); } resultOI = TypeInfoUtils.getStandardWritableObjectInspectorFromTypeInfo( (commonInfo == null) ? TypeInfoFactory.doubleTypeInfo : commonInfo); for (int i = 0; i < arguments.length; i++) { converters[i] = ObjectInspectorConverters.getConverter(arguments[i], resultOI); } return resultOI; }
tgtDT = FunctionRegistry.getCommonClassForComparison(func.getChildren().get(0) .getTypeInfo(), func.getChildren().get(1).getTypeInfo()); } else if (isWhenCase) {
} else { compareType = CompareType.NEED_CONVERT; TypeInfo compareType = FunctionRegistry.getCommonClassForComparison( oiTypeInfo0, oiTypeInfo1);
} else { compareType = CompareType.NEED_CONVERT; TypeInfo compareType = FunctionRegistry.getCommonClassForComparison( oiTypeInfo0, oiTypeInfo1);