Search in sources :

Example 1 with ConversionHelper

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

the class GenericUDFBridge method initialize.

@Override
public ObjectInspector initialize(ObjectInspector[] arguments) throws UDFArgumentException {
    try {
        udf = getUdfClassInternal().newInstance();
    } catch (Exception e) {
        throw new UDFArgumentException("Unable to instantiate UDF implementation class " + udfClassName + ": " + e);
    }
    // Resolve for the method based on argument types
    ArrayList<TypeInfo> argumentTypeInfos = new ArrayList<TypeInfo>(arguments.length);
    for (ObjectInspector argument : arguments) {
        argumentTypeInfos.add(TypeInfoUtils.getTypeInfoFromObjectInspector(argument));
    }
    udfMethod = udf.getResolver().getEvalMethod(argumentTypeInfos);
    udfMethod.setAccessible(true);
    // Create parameter converters
    conversionHelper = new ConversionHelper(udfMethod, arguments);
    // Create the non-deferred realArgument
    realArguments = new Object[arguments.length];
    // Get the return ObjectInspector.
    ObjectInspector returnOI = ObjectInspectorFactory.getReflectionObjectInspector(udfMethod.getGenericReturnType(), ObjectInspectorOptions.JAVA);
    return returnOI;
}
Also used : UDFArgumentException(org.apache.hadoop.hive.ql.exec.UDFArgumentException) ObjectInspector(org.apache.hadoop.hive.serde2.objectinspector.ObjectInspector) ArrayList(java.util.ArrayList) ConversionHelper(org.apache.hadoop.hive.ql.udf.generic.GenericUDFUtils.ConversionHelper) TypeInfo(org.apache.hadoop.hive.serde2.typeinfo.TypeInfo) UDFArgumentException(org.apache.hadoop.hive.ql.exec.UDFArgumentException) HiveException(org.apache.hadoop.hive.ql.metadata.HiveException)

Aggregations

ArrayList (java.util.ArrayList)1 UDFArgumentException (org.apache.hadoop.hive.ql.exec.UDFArgumentException)1 HiveException (org.apache.hadoop.hive.ql.metadata.HiveException)1 ConversionHelper (org.apache.hadoop.hive.ql.udf.generic.GenericUDFUtils.ConversionHelper)1 ObjectInspector (org.apache.hadoop.hive.serde2.objectinspector.ObjectInspector)1 TypeInfo (org.apache.hadoop.hive.serde2.typeinfo.TypeInfo)1