in src/main/java/org/apache/datasketches/hive/tuple/DataToArrayOfDoublesSketchUDAF.java [56:93]
public GenericUDAFEvaluator getEvaluator(final GenericUDAFParameterInfo info) throws SemanticException {
final ObjectInspector[] inspectors = info.getParameterObjectInspectors();
if (inspectors.length < 2) {
throw new UDFArgumentException("Expected at least 2 arguments");
}
ObjectInspectorValidator.validateCategoryPrimitive(inspectors[0], 0);
int numValues = 0;
while ((numValues + 1) < inspectors.length) {
ObjectInspectorValidator.validateCategoryPrimitive(inspectors[numValues + 1], numValues + 1);
final PrimitiveObjectInspector primitiveInspector =
(PrimitiveObjectInspector) inspectors[numValues + 1];
if (primitiveInspector.getPrimitiveCategory() != PrimitiveCategory.DOUBLE) { break; }
numValues++;
}
if (numValues == 0) {
throw new UDFArgumentException("Expected at least 1 double value");
}
// nominal number of entries
if (inspectors.length > (numValues + 1)) {
ObjectInspectorValidator.validateIntegralParameter(inspectors[numValues + 1], numValues + 1);
}
// sampling probability
if (inspectors.length > (numValues + 2)) {
ObjectInspectorValidator.validateGivenPrimitiveCategory(inspectors[numValues + 2],
numValues + 2, PrimitiveCategory.FLOAT);
}
// there must be nothing after sampling probability
if (inspectors.length > (numValues + 3)) {
throw new UDFArgumentException("Unexpected argument " + (numValues + 4));
}
return new DataToArrayOfDoublesSketchEvaluator();
}