Search in sources :

Example 6 with ScalarFunctionImplementationChoice

use of com.facebook.presto.operator.scalar.ScalarFunctionImplementationChoice in project presto by prestodb.

the class FunctionInvokerProvider method createFunctionInvoker.

public FunctionInvoker createFunctionInvoker(FunctionHandle functionHandle, Optional<InvocationConvention> invocationConvention) {
    JavaScalarFunctionImplementation functionImplementation = functionAndTypeManager.getJavaScalarFunctionImplementation(functionHandle);
    for (ScalarFunctionImplementationChoice choice : getAllScalarFunctionImplementationChoices(functionImplementation)) {
        if (checkChoice(choice.getArgumentProperties(), choice.isNullable(), choice.hasProperties(), invocationConvention)) {
            return new FunctionInvoker(choice.getMethodHandle());
        }
    }
    checkState(invocationConvention.isPresent());
    throw new PrestoException(FUNCTION_NOT_FOUND, format("Dependent function implementation (%s) with convention (%s) is not available", functionHandle, invocationConvention.toString()));
}
Also used : JavaScalarFunctionImplementation(com.facebook.presto.spi.function.JavaScalarFunctionImplementation) ScalarFunctionImplementationChoice(com.facebook.presto.operator.scalar.ScalarFunctionImplementationChoice) PrestoException(com.facebook.presto.spi.PrestoException)

Aggregations

ScalarFunctionImplementationChoice (com.facebook.presto.operator.scalar.ScalarFunctionImplementationChoice)6 ArrayList (java.util.ArrayList)4 ArgumentProperty (com.facebook.presto.operator.scalar.ScalarFunctionImplementationChoice.ArgumentProperty)3 MethodHandle (java.lang.invoke.MethodHandle)3 SqlFunctionProperties (com.facebook.presto.common.function.SqlFunctionProperties)2 Type (com.facebook.presto.common.type.Type)2 BuiltInScalarFunctionImplementation (com.facebook.presto.operator.scalar.BuiltInScalarFunctionImplementation)2 JavaScalarFunctionImplementation (com.facebook.presto.spi.function.JavaScalarFunctionImplementation)2 Binding (com.facebook.presto.bytecode.Binding)1 BytecodeBlock (com.facebook.presto.bytecode.BytecodeBlock)1 BytecodeNode (com.facebook.presto.bytecode.BytecodeNode)1 Variable (com.facebook.presto.bytecode.Variable)1 LabelNode (com.facebook.presto.bytecode.instruction.LabelNode)1 FunctionAndTypeManager (com.facebook.presto.metadata.FunctionAndTypeManager)1 MethodAndNativeContainerTypes (com.facebook.presto.metadata.PolymorphicScalarFunctionBuilder.MethodAndNativeContainerTypes)1 MethodsGroup (com.facebook.presto.metadata.PolymorphicScalarFunctionBuilder.MethodsGroup)1 SpecializeContext (com.facebook.presto.metadata.PolymorphicScalarFunctionBuilder.SpecializeContext)1 VALUE_TYPE (com.facebook.presto.operator.scalar.ScalarFunctionImplementationChoice.ArgumentType.VALUE_TYPE)1 PrestoException (com.facebook.presto.spi.PrestoException)1 FunctionHandle (com.facebook.presto.spi.function.FunctionHandle)1