@Override
public GenericUDAFEvaluator getEvaluator(TypeInfo[] parameters)
throws SemanticException {
if (parameters.length != 2 ) {
throw new UDFArgumentTypeException(parameters.length - 1,
"Exactly two arguments are expected.");
}
if (parameters[0].getCategory() != ObjectInspector.Category.PRIMITIVE) {
throw new UDFArgumentTypeException(0,
"Only primitive type arguments are accepted but "
+ parameters[0].getTypeName() + " is passed.");
}
switch (((PrimitiveTypeInfo) parameters[0]).getPrimitiveCategory()) {
case BOOLEAN:
return new GenericUDAFBooleanStatsEvaluator();
case BYTE:
case SHORT:
case INT:
case LONG:
case TIMESTAMP:
return new GenericUDAFLongStatsEvaluator();
case FLOAT:
case DOUBLE:
return new GenericUDAFDoubleStatsEvaluator();
case STRING:
return new GenericUDAFStringStatsEvaluator();
case BINARY:
return new GenericUDAFBinaryStatsEvaluator();
default:
throw new UDFArgumentTypeException(0,
"Only integer/long/timestamp/float/double/string/binary/boolean type argument " +
"is accepted but "
+ parameters[0].getTypeName() + " is passed.");
}
}