public GenericUDAFExecutor(GenericUDAFResolver2 evaluatorFactory, GenericUDAFParameterInfo info) throws Exception { this.evaluatorFactory = evaluatorFactory; this.info = info; GenericUDAFEvaluator eval0 = evaluatorFactory.getEvaluator(info); partialOIs = new ObjectInspector[] { eval0.init(GenericUDAFEvaluator.Mode.PARTIAL1, info.getParameterObjectInspectors()) }; }
private List<Object> runPartial1(List<Object[]> values) throws Exception { List<Object> ret = new ArrayList<>(); int batchSize = 1; Iterator<Object[]> iter = values.iterator(); do { GenericUDAFEvaluator eval = evaluatorFactory.getEvaluator(info); eval.init(GenericUDAFEvaluator.Mode.PARTIAL1, info.getParameterObjectInspectors()); AggregationBuffer buf = eval.getNewAggregationBuffer(); for (int i = 0; i < batchSize - 1 && iter.hasNext(); i++) { eval.iterate(buf, iter.next()); } batchSize <<= 1; ret.add(eval.terminatePartial(buf)); // back-check to force at least 1 output; and this should have a partial which is empty } while (iter.hasNext()); return ret; }
private Object runComplete(List<Object[]> values) throws SemanticException, HiveException { GenericUDAFEvaluator eval = evaluatorFactory.getEvaluator(info); eval.init(GenericUDAFEvaluator.Mode.COMPLETE, info.getParameterObjectInspectors()); AggregationBuffer agg = eval.getNewAggregationBuffer(); for (Object[] parameters : values) { eval.iterate(agg, parameters); } return eval.terminate(agg); }
throws SemanticException { ObjectInspector[] paramOIs = parameters.getParameterObjectInspectors(); String fNm = functionName();
throws SemanticException { ObjectInspector[] paramOIs = parameters.getParameterObjectInspectors(); String fNm = functionName();
@Override public GenericUDAFEvaluator getEvaluator(GenericUDAFParameterInfo info) throws SemanticException { ObjectInspector[] parameters = info.getParameterObjectInspectors(); if (parameters.length != 2 && parameters.length != 3) { throw new UDFArgumentTypeException(parameters.length - 1,
@Override public GenericUDAFEvaluator getEvaluator(GenericUDAFParameterInfo info) throws SemanticException { ObjectInspector[] parameters = info.getParameterObjectInspectors(); if (parameters.length != 2 && parameters.length != 3) { throw new UDFArgumentTypeException(parameters.length - 1,
@Override public GenericUDAFEvaluator getEvaluator(GenericUDAFParameterInfo info) throws SemanticException { ObjectInspector[] OIs = info.getParameterObjectInspectors(); if (OIs.length != 2) { throw new UDFArgumentLengthException("Specify two arguments."); } if (!HiveUtils.isNumberListOI(OIs[0])) { throw new UDFArgumentTypeException(0, "Only array<number> type argument is acceptable but " + OIs[0].getTypeName() + " was passed as `matrix0_row`"); } if (!HiveUtils.isNumberListOI(OIs[1])) { throw new UDFArgumentTypeException(1, "Only array<number> type argument is acceptable but " + OIs[1].getTypeName() + " was passed as `matrix1_row`"); } return new TransposeAndDotUDAFEvaluator(); }
@Override public GenericUDAFEvaluator getEvaluator(GenericUDAFParameterInfo info) throws SemanticException { final ObjectInspector[] OIs = info.getParameterObjectInspectors(); if (OIs.length != 2) { throw new UDFArgumentLengthException("Specify two arguments: " + OIs.length); } if (!HiveUtils.isNumberListOI(OIs[0])) { throw new UDFArgumentTypeException(0, "Only array<number> type argument is acceptable but " + OIs[0].getTypeName() + " was passed as `features`"); } if (!HiveUtils.isListOI(OIs[1]) || !HiveUtils.isIntegerOI( ((ListObjectInspector) OIs[1]).getListElementObjectInspector())) { throw new UDFArgumentTypeException(1, "Only array<int> type argument is acceptable but " + OIs[1].getTypeName() + " was passed as `labels`"); } return new SignalNoiseRatioUDAFEvaluator(); }
throws SemanticException { ObjectInspector[] paramOIs = parameters.getParameterObjectInspectors(); String fNm = functionName();
@Override public GenericUDAFEvaluator getEvaluator(GenericUDAFParameterInfo info) throws SemanticException { @SuppressWarnings("deprecation") TypeInfo[] typeInfo = info.getParameters(); if (typeInfo.length != 2 && typeInfo.length != 3) { throw new UDFArgumentTypeException(typeInfo.length - 1, "Expecting two or three arguments: " + typeInfo.length); } if (typeInfo[0].getCategory() != ObjectInspector.Category.PRIMITIVE) { throw new UDFArgumentTypeException(0, "Only primitive type arguments are accepted for the key but " + typeInfo[0].getTypeName() + " was passed as parameter 1."); } boolean reverseOrder = false; if (typeInfo.length == 3) { if (HiveUtils.isBooleanTypeInfo(typeInfo[2]) == false) { throw new UDFArgumentTypeException(2, "The three argument must be boolean type: " + typeInfo[2].getTypeName()); } ObjectInspector[] argOIs = info.getParameterObjectInspectors(); reverseOrder = HiveUtils.getConstBoolean(argOIs[2]); } if (reverseOrder) { return new ReverseOrdereMapEvaluator(); } else { return new NaturalOrdereMapEvaluator(); } }
@Override public GenericUDAFEvaluator getEvaluator(GenericUDAFParameterInfo info) throws SemanticException { ObjectInspector[] OIs = info.getParameterObjectInspectors(); if (OIs.length != 2 && OIs.length != 3) { throw new UDFArgumentLengthException("Specify two or three arguments."); } if (!HiveUtils.isNumberOI(OIs[0])) { throw new UDFArgumentTypeException(0, "Only number type argument is acceptable but " + OIs[0].getTypeName() + " was passed as `weight`"); } if (!HiveUtils.isIntegerOI(OIs[1])) { throw new UDFArgumentTypeException(1, "Only int type argument is acceptable but " + OIs[1].getTypeName() + " was passed as `num_of_bins`"); } if (OIs.length == 3) { if (!HiveUtils.isBooleanOI(OIs[2])) { throw new UDFArgumentTypeException(2, "Only boolean type argument is acceptable but " + OIs[2].getTypeName() + " was passed as `auto_shrink`"); } } return new BuildBinsUDAFEvaluator(); }
@Override public GenericUDAFEvaluator getEvaluator(GenericUDAFParameterInfo info) throws SemanticException { @SuppressWarnings("deprecation") TypeInfo[] typeInfo = info.getParameters(); ObjectInspector[] argOIs = info.getParameterObjectInspectors(); if ((typeInfo.length == 1) || (typeInfo.length == 2 && HiveUtils.isConstString(argOIs[1]))) { // sort values by value itself w/o key if (typeInfo[0].getCategory() != ObjectInspector.Category.PRIMITIVE) { throw new UDFArgumentTypeException(0, "Only primitive type arguments are accepted for value but " + typeInfo[0].getTypeName() + " was passed as the first parameter."); } } else if ((typeInfo.length == 2) || (typeInfo.length == 3 && HiveUtils.isConstString(argOIs[2]))) { // sort values by key if (typeInfo[1].getCategory() != ObjectInspector.Category.PRIMITIVE) { throw new UDFArgumentTypeException(1, "Only primitive type arguments are accepted for key but " + typeInfo[1].getTypeName() + " was passed as the second parameter."); } } else { throw new UDFArgumentTypeException(typeInfo.length - 1, "Number of arguments must be in [1, 3] including constant string for options: " + typeInfo.length); } return new UDAFToOrderedListEvaluator(); }
int size = 0; if (typeInfo.length == 3) { ObjectInspector[] argOIs = info.getParameterObjectInspectors(); ObjectInspector argOI2 = argOIs[2]; if (HiveUtils.isConstBoolean(argOI2)) {
@Override public GenericUDAFEvaluator getEvaluator(GenericUDAFParameterInfo info) throws SemanticException { ObjectInspector[] parameters = info.getParameterObjectInspectors(); if (parameters.length != 2 && parameters.length != 3) { throw new UDFArgumentTypeException(parameters.length - 1,