Search in sources :

Example 1 with SimpleGenericUDAFParameterInfo

use of org.apache.hadoop.hive.ql.udf.generic.SimpleGenericUDAFParameterInfo in project hive by apache.

the class Registry method getGenericWindowingEvaluator.

public GenericUDAFEvaluator getGenericWindowingEvaluator(String functionName, List<ObjectInspector> argumentOIs, boolean isDistinct, boolean isAllColumns, boolean respectNulls) throws SemanticException {
    functionName = functionName.toLowerCase();
    WindowFunctionInfo info = getWindowFunctionInfo(functionName);
    if (info == null) {
        return null;
    }
    if (!functionName.equals(FunctionRegistry.LEAD_FUNC_NAME) && !functionName.equals(FunctionRegistry.LAG_FUNC_NAME)) {
        return getGenericUDAFEvaluator(functionName, argumentOIs, true, isDistinct, isAllColumns, respectNulls);
    }
    // this must be lead/lag UDAF
    ObjectInspector[] args = new ObjectInspector[argumentOIs.size()];
    GenericUDAFResolver udafResolver = info.getGenericUDAFResolver();
    GenericUDAFParameterInfo paramInfo = new SimpleGenericUDAFParameterInfo(argumentOIs.toArray(args), true, isDistinct, isAllColumns);
    return ((GenericUDAFResolver2) udafResolver).getEvaluator(paramInfo);
}
Also used : SimpleGenericUDAFParameterInfo(org.apache.hadoop.hive.ql.udf.generic.SimpleGenericUDAFParameterInfo) GenericUDAFResolver2(org.apache.hadoop.hive.ql.udf.generic.GenericUDAFResolver2) ObjectInspector(org.apache.hadoop.hive.serde2.objectinspector.ObjectInspector) GenericUDAFParameterInfo(org.apache.hadoop.hive.ql.udf.generic.GenericUDAFParameterInfo) SimpleGenericUDAFParameterInfo(org.apache.hadoop.hive.ql.udf.generic.SimpleGenericUDAFParameterInfo) GenericUDAFResolver(org.apache.hadoop.hive.ql.udf.generic.GenericUDAFResolver)

Example 2 with SimpleGenericUDAFParameterInfo

use of org.apache.hadoop.hive.ql.udf.generic.SimpleGenericUDAFParameterInfo in project hive by apache.

the class Registry method getGenericUDAFEvaluator.

/**
 * Get the GenericUDAF evaluator for the name and argumentClasses.
 *
 * @param name         the name of the UDAF
 * @param argumentOIs
 * @param isDistinct
 * @param isAllColumns
 * @return The UDAF evaluator
 */
@SuppressWarnings("deprecation")
public GenericUDAFEvaluator getGenericUDAFEvaluator(String name, List<ObjectInspector> argumentOIs, boolean isWindowing, boolean isDistinct, boolean isAllColumns, boolean respectNulls) throws SemanticException {
    GenericUDAFResolver udafResolver = getGenericUDAFResolver(name);
    if (udafResolver == null) {
        return null;
    }
    GenericUDAFEvaluator udafEvaluator;
    ObjectInspector[] args = new ObjectInspector[argumentOIs.size()];
    // generics + arrays.
    for (int ii = 0; ii < argumentOIs.size(); ++ii) {
        args[ii] = argumentOIs.get(ii);
    }
    GenericUDAFParameterInfo paramInfo = new SimpleGenericUDAFParameterInfo(args, isWindowing, isDistinct, isAllColumns, respectNulls);
    if (udafResolver instanceof GenericUDAFResolver2) {
        udafEvaluator = ((GenericUDAFResolver2) udafResolver).getEvaluator(paramInfo);
    } else {
        udafEvaluator = udafResolver.getEvaluator(paramInfo.getParameters());
    }
    return udafEvaluator;
}
Also used : SimpleGenericUDAFParameterInfo(org.apache.hadoop.hive.ql.udf.generic.SimpleGenericUDAFParameterInfo) GenericUDAFResolver2(org.apache.hadoop.hive.ql.udf.generic.GenericUDAFResolver2) ObjectInspector(org.apache.hadoop.hive.serde2.objectinspector.ObjectInspector) GenericUDAFEvaluator(org.apache.hadoop.hive.ql.udf.generic.GenericUDAFEvaluator) GenericUDAFParameterInfo(org.apache.hadoop.hive.ql.udf.generic.GenericUDAFParameterInfo) SimpleGenericUDAFParameterInfo(org.apache.hadoop.hive.ql.udf.generic.SimpleGenericUDAFParameterInfo) GenericUDAFResolver(org.apache.hadoop.hive.ql.udf.generic.GenericUDAFResolver)

Aggregations

GenericUDAFParameterInfo (org.apache.hadoop.hive.ql.udf.generic.GenericUDAFParameterInfo)2 GenericUDAFResolver (org.apache.hadoop.hive.ql.udf.generic.GenericUDAFResolver)2 GenericUDAFResolver2 (org.apache.hadoop.hive.ql.udf.generic.GenericUDAFResolver2)2 SimpleGenericUDAFParameterInfo (org.apache.hadoop.hive.ql.udf.generic.SimpleGenericUDAFParameterInfo)2 ObjectInspector (org.apache.hadoop.hive.serde2.objectinspector.ObjectInspector)2 GenericUDAFEvaluator (org.apache.hadoop.hive.ql.udf.generic.GenericUDAFEvaluator)1