@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]); boolean c = ObjectInspectorUtils.compareTypes(oi, PrimitiveObjectInspectorFactory.writableIntObjectInspector); if (!c) { throw new UDFArgumentTypeException(0, "Number of tiles must be an int expression"); } return new GenericUDAFNTileEvaluator(); }
ObjectInspector child2 = ((ListObjectInspector) o2).getListElementObjectInspector(); return compareTypes(child1, child2); ObjectInspector childKey2 = mapOI2.getMapKeyObjectInspector(); if (compareTypes(childKey1, childKey2)) { ObjectInspector childVal1 = mapOI1.getMapValueObjectInspector(); ObjectInspector childVal2 = mapOI2.getMapValueObjectInspector(); if (compareTypes(childVal1, childVal2)) { return true; StructField field2 = it2.next(); if (!compareTypes(field1.getFieldObjectInspector(), field2.getFieldObjectInspector())) { return false; Iterator<? extends ObjectInspector> it2 = ois2.iterator(); while (it1.hasNext()) { if (!compareTypes(it1.next(), it2.next())) { return false;
if (!ObjectInspectorUtils.compareTypes(arrayElementOI, valueOI)) { throw new UDFArgumentTypeException(VALUE_IDX, "\"" + arrayElementOI.getTypeName() + "\""
if (!ObjectInspectorUtils.compareTypes(arrayElementOI, valueOI)) { throw new UDFArgumentTypeException(VALUE_IDX, "\"" + arrayElementOI.getTypeName() + "\""
for (int i = 1; i < args.length; ++i) { ObjectInspector argInsp = args[i]; if (!ObjectInspectorUtils.compareTypes(first, argInsp)) { throw new UDFArgumentException("Combine must either be all maps or all lists of the same type"); for (int i = 1; i < args.length; ++i) { ObjectInspector argInsp = args[i]; if (!ObjectInspectorUtils.compareTypes(first, argInsp)) { throw new UDFArgumentException("Combine must either be all maps or all lists of the same type");
@Override public ObjectInspector initialize(ObjectInspector[] arguments) throws UDFArgumentException { // Check if two arguments were passed if (arguments.length != ARG_COUNT) { throw new UDFArgumentException("The function " + FUNC_NAME + " accepts " + ARG_COUNT + " arguments."); } // Check if ARRAY_IDX argument is of category LIST if (!arguments[ARRAY_IDX].getCategory().equals(Category.LIST)) { throw new UDFArgumentTypeException(ARRAY_IDX, "\"" + "LIST" + "\" " + "expected at function " + FUNC_NAME + ", but " + "\"" + arguments[ARRAY_IDX].getTypeName() + "\" " + "is found"); } arrayOI = (ListObjectInspector) arguments[ARRAY_IDX]; arrayElementOI = arrayOI.getListElementObjectInspector(); valueOI = arguments[VALUE_IDX]; // Check if list element and value are of same type if (!ObjectInspectorUtils.compareTypes(arrayElementOI, valueOI)) { throw new UDFArgumentTypeException(VALUE_IDX, "\"" + arrayElementOI.getTypeName() + "\"" + " expected at function " + FUNC_NAME + ", but " + "\"" + valueOI.getTypeName() + "\"" + " is found"); } // Check if the comparison is supported for this type if (!ObjectInspectorUtils.compareSupported(valueOI)) { throw new UDFArgumentException("The function " + FUNC_NAME + " does not support comparison for " + "\"" + valueOI.getTypeName() + "\"" + " types"); } result = new IntWritable(-1); return PrimitiveObjectInspectorFactory.writableIntObjectInspector; }
@Override public ObjectInspector initialize(ObjectInspector[] arg0) throws UDFArgumentException { if (arg0.length < 2) { throw new UDFArgumentException(" Expecting at least two arrays as arguments "); } ObjectInspector first = arg0[0]; listInspectorArr = new ListObjectInspector[arg0.length]; if (first.getCategory() == Category.LIST) { listInspectorArr[0] = (ListObjectInspector) first; } else { throw new UDFArgumentException(" Expecting an array as first argument "); } for (int i = 1; i < arg0.length; ++i) { if (arg0[i].getCategory() != Category.LIST) { throw new UDFArgumentException(" Expecting arrays arguments "); } ListObjectInspector checkInspector = (ListObjectInspector) arg0[i]; if (!ObjectInspectorUtils.compareTypes(listInspectorArr[0].getListElementObjectInspector(), checkInspector.getListElementObjectInspector())) { throw new UDFArgumentException(" Array types must match " + listInspectorArr[0].getTypeName() + " != " + checkInspector.getTypeName()); } listInspectorArr[i] = checkInspector; } retValInspector = (StandardListObjectInspector) ObjectInspectorUtils.getStandardObjectInspector(first); return retValInspector; }
@Override public ObjectInspector initialize(ObjectInspector[] arg0) throws UDFArgumentException { if (arg0.length < 2) { throw new UDFArgumentException(" Expecting at least two arrays as arguments "); } ObjectInspector first = arg0[0]; listInspectorArr = new ListObjectInspector[arg0.length]; if (first.getCategory() == Category.LIST) { listInspectorArr[0] = (ListObjectInspector) first; } else { throw new UDFArgumentException(" Expecting an array as first argument "); } for (int i = 1; i < arg0.length; ++i) { if (arg0[i].getCategory() != Category.LIST) { throw new UDFArgumentException(" Expecting arrays arguments "); } ListObjectInspector checkInspector = (ListObjectInspector) arg0[i]; if (!ObjectInspectorUtils.compareTypes(listInspectorArr[0].getListElementObjectInspector(), checkInspector.getListElementObjectInspector())) { throw new UDFArgumentException(" Array types must match " + listInspectorArr[0].getTypeName() + " != " + checkInspector.getTypeName()); } listInspectorArr[i] = checkInspector; } retValInspector = (StandardListObjectInspector) ObjectInspectorUtils.getStandardObjectInspector(first); return retValInspector; }
@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 ObjectInspector initialize(ObjectInspector[] arguments) throws UDFArgumentException { mapOI = (MapObjectInspector)arguments[0]; arrayOI = (ListObjectInspector)arguments[1]; // Check map against key. ObjectInspector mapItemOI = mapOI.getMapKeyObjectInspector(); ObjectInspector listItemOI = arrayOI.getListElementObjectInspector(); if (!ObjectInspectorUtils.compareTypes(mapItemOI, listItemOI)) { throw new UDFArgumentException("Map key type (" + mapItemOI + ") must match " + "list element type (" + listItemOI + ")."); } return ObjectInspectorUtils.getStandardObjectInspector(mapOI, ObjectInspectorCopyOption.WRITABLE); }
ObjectInspector child2 = ((ListObjectInspector) o2).getListElementObjectInspector(); return compareTypes(child1, child2); ObjectInspector childKey2 = mapOI2.getMapKeyObjectInspector(); if (compareTypes(childKey1, childKey2)) { ObjectInspector childVal1 = mapOI1.getMapValueObjectInspector(); ObjectInspector childVal2 = mapOI2.getMapValueObjectInspector(); if (compareTypes(childVal1, childVal2)) { return true; StructField field2 = it2.next(); if (!compareTypes(field1.getFieldObjectInspector(), field2.getFieldObjectInspector())) { return false; Iterator<? extends ObjectInspector> it2 = ois2.iterator(); while (it1.hasNext()) { if (!compareTypes(it1.next(), it2.next())) { return false;
ObjectInspector child2 = ((ListObjectInspector) o2).getListElementObjectInspector(); return compareTypes(child1, child2); ObjectInspector childKey2 = mapOI2.getMapKeyObjectInspector(); if (compareTypes(childKey1, childKey2)) { ObjectInspector childVal1 = mapOI1.getMapValueObjectInspector(); ObjectInspector childVal2 = mapOI2.getMapValueObjectInspector(); if (compareTypes(childVal1, childVal2)) { return true; StructField field2 = it2.next(); if (!compareTypes(field1.getFieldObjectInspector(), field2.getFieldObjectInspector())) { return false; Iterator<? extends ObjectInspector> it2 = ois2.iterator(); while (it1.hasNext()) { if (!compareTypes(it1.next(), it2.next())) { return false;
@Override public ObjectInspector initialize(@Nonnull ObjectInspector[] argOIs) throws UDFArgumentException { final int argLength = argOIs.length; if (argLength < 2) { throw new UDFArgumentLengthException("Expecting at least two arrays as arguments: " + argLength); } ListObjectInspector[] argListOIs = new ListObjectInspector[argLength]; ListObjectInspector arg0ListOI = HiveUtils.asListOI(argOIs[0]); ObjectInspector arg0ElemOI = arg0ListOI.getListElementObjectInspector(); argListOIs[0] = arg0ListOI; for (int i = 1; i < argLength; i++) { ListObjectInspector listOI = HiveUtils.asListOI(argOIs[i]); if (!ObjectInspectorUtils.compareTypes(listOI.getListElementObjectInspector(), arg0ElemOI)) { throw new UDFArgumentException("Array types does not match: " + arg0ElemOI.getTypeName() + " != " + listOI.getListElementObjectInspector().getTypeName()); } argListOIs[i] = listOI; } this.argListOIs = argListOIs; this.result = new ArrayList<Object>(); return ObjectInspectorUtils.getStandardObjectInspector(arg0ListOI); }
@Override public ObjectInspector initialize(@Nonnull ObjectInspector[] argOIs) throws UDFArgumentException { final int argLength = argOIs.length; if (argLength < 2) { throw new UDFArgumentLengthException( "Expecting at least two arrays as arguments: " + argLength); } ListObjectInspector[] argListOIs = new ListObjectInspector[argLength]; ListObjectInspector arg0ListOI = HiveUtils.asListOI(argOIs[0]); ObjectInspector arg0ElemOI = arg0ListOI.getListElementObjectInspector(); argListOIs[0] = arg0ListOI; for (int i = 1; i < argLength; i++) { ListObjectInspector listOI = HiveUtils.asListOI(argOIs[i]); if (!ObjectInspectorUtils.compareTypes(listOI.getListElementObjectInspector(), arg0ElemOI)) { throw new UDFArgumentException( "Array types does not match: " + arg0ElemOI.getTypeName() + " != " + listOI.getListElementObjectInspector().getTypeName()); } argListOIs[i] = listOI; } this.argListOIs = argListOIs; this.result = new ArrayList<Object>(); return ObjectInspectorUtils.getStandardObjectInspector(arg0ListOI); }
@Override public ObjectInspector initialize(ObjectInspector[] argOIs) throws UDFArgumentException { if (argOIs.length != 2) { throw new UDFArgumentLengthException( "Expected two arguments for map_filter_keys: " + argOIs.length); } this.mapOI = HiveUtils.asMapOI(argOIs[0]); this.listOI = HiveUtils.asListOI(argOIs[1]); ObjectInspector mapKeyOI = mapOI.getMapKeyObjectInspector(); ObjectInspector filterKeyOI = listOI.getListElementObjectInspector(); if (!ObjectInspectorUtils.compareTypes(mapKeyOI, filterKeyOI)) { throw new UDFArgumentException("Element types does not match: mapKey " + mapKeyOI.getTypeName() + ", filterKey" + filterKeyOI.getTypeName()); } return ObjectInspectorUtils.getStandardObjectInspector(mapOI, ObjectInspectorCopyOption.WRITABLE); }
@Override public ObjectInspector initialize(ObjectInspector[] argOIs) throws UDFArgumentException { if (argOIs.length != 2) { throw new UDFArgumentLengthException( "Expected two arguments for map_filter_keys: " + argOIs.length); } this.mapOI = HiveUtils.asMapOI(argOIs[0]); this.listOI = HiveUtils.asListOI(argOIs[1]); ObjectInspector mapKeyOI = mapOI.getMapKeyObjectInspector(); ObjectInspector filterKeyOI = listOI.getListElementObjectInspector(); if (!ObjectInspectorUtils.compareTypes(mapKeyOI, filterKeyOI)) { throw new UDFArgumentException("Element types does not match: mapKey " + mapKeyOI.getTypeName() + ", filterKey" + filterKeyOI.getTypeName()); } return ObjectInspectorUtils.getStandardObjectInspector(mapOI, ObjectInspectorCopyOption.WRITABLE); }
@Override public ObjectInspector initialize(ObjectInspector[] argOIs) throws UDFArgumentException { if (argOIs.length < 2) { throw new UDFArgumentException("Expecting at least two arrays as arguments"); } ListObjectInspector[] listOIs = new ListObjectInspector[argOIs.length]; ListObjectInspector arg0OI = HiveUtils.asListOI(argOIs[0]); listOIs[0] = arg0OI; ObjectInspector arg0ElemOI = arg0OI.getListElementObjectInspector(); for (int i = 1; i < argOIs.length; ++i) { ListObjectInspector checkOI = HiveUtils.asListOI(argOIs[i]); if (!ObjectInspectorUtils.compareTypes(arg0ElemOI, checkOI.getListElementObjectInspector())) { throw new UDFArgumentException("Array types does not match: " + arg0OI.getTypeName() + " != " + checkOI.getTypeName()); } listOIs[i] = checkOI; } this._listOIs = listOIs; return ObjectInspectorFactory.getStandardListObjectInspector( ObjectInspectorUtils.getStandardObjectInspector(arg0ElemOI, ObjectInspectorCopyOption.WRITABLE)); }
if (!ObjectInspectorUtils.compareTypes(arrayElementOI, valueOI)) { throw new UDFArgumentTypeException(VALUE_IDX, "\"" + arrayElementOI.getTypeName() + "\""
if (!ObjectInspectorUtils.compareTypes(arrayElementOI, valueOI)) { throw new UDFArgumentTypeException(VALUE_IDX, "\"" + arrayElementOI.getTypeName() + "\""