use of com.facebook.presto.spi.function.ScalarFunctionImplementation in project presto by prestodb.
the class FunctionCallCodeGenerator method generateCall.
public BytecodeNode generateCall(FunctionHandle functionHandle, BytecodeGeneratorContext context, Type returnType, List<RowExpression> arguments, Optional<Variable> outputBlockVariable) {
FunctionAndTypeManager functionAndTypeManager = context.getFunctionManager();
ScalarFunctionImplementation function = functionAndTypeManager.getScalarFunctionImplementation(functionHandle);
checkArgument(function instanceof JavaScalarFunctionImplementation, format("FunctionCallCodeGenerator only handles JavaScalarFunctionImplementation, get %s", function.getClass().getName()));
JavaScalarFunctionImplementation javaFunction = (JavaScalarFunctionImplementation) function;
List<BytecodeNode> argumentsBytecode = new ArrayList<>();
ScalarFunctionImplementationChoice choice = getAllScalarFunctionImplementationChoices(javaFunction).get(0);
for (int i = 0; i < arguments.size(); i++) {
RowExpression argument = arguments.get(i);
ArgumentProperty argumentProperty = choice.getArgumentProperty(i);
if (argumentProperty.getArgumentType() == VALUE_TYPE) {
argumentsBytecode.add(context.generate(argument, Optional.empty()));
} else {
argumentsBytecode.add(context.generate(argument, Optional.empty(), Optional.of(argumentProperty.getLambdaInterface())));
}
}
return context.generateCall(functionAndTypeManager.getFunctionMetadata(functionHandle).getName().getObjectName(), javaFunction, argumentsBytecode, outputBlockVariable.map(variable -> new OutputBlockVariableAndType(variable, returnType)));
}
use of com.facebook.presto.spi.function.ScalarFunctionImplementation in project presto by prestodb.
the class FunctionAndTypeManager method getJavaScalarFunctionImplementation.
public JavaScalarFunctionImplementation getJavaScalarFunctionImplementation(FunctionHandle functionHandle) {
ScalarFunctionImplementation implementation = getScalarFunctionImplementation(functionHandle);
checkArgument(implementation instanceof JavaScalarFunctionImplementation, format("Implementation of function %s is not a JavaScalarFunctionImplementation", getFunctionMetadata(functionHandle).getName()));
return (JavaScalarFunctionImplementation) implementation;
}
Aggregations