@Override public MethodHandle resolve(BoundVariables boundVariables, TypeManager typeManager, FunctionRegistry functionRegistry) { Signature signature = applyBoundVariables(this.signature, boundVariables, this.signature.getArgumentTypes().size()); if (invocationConvention.isPresent()) { return functionRegistry.getFunctionInvokerProvider().createFunctionInvoker(signature, invocationConvention).methodHandle(); } else { return functionRegistry.getScalarFunctionImplementation(signature).getMethodHandle(); } }
@Override public MethodHandle resolve(BoundVariables boundVariables, TypeManager typeManager, FunctionRegistry functionRegistry) { Signature signature = applyBoundVariables(this.signature, boundVariables, this.signature.getArgumentTypes().size()); if (invocationConvention.isPresent()) { return functionRegistry.getFunctionInvokerProvider().createFunctionInvoker(signature, invocationConvention).methodHandle(); } else { return functionRegistry.getScalarFunctionImplementation(signature).getMethodHandle(); } }
@Override public ScalarFunctionImplementation specialize(BoundVariables boundVariables, int arity, TypeManager typeManager, FunctionRegistry functionRegistry) { ImmutableList.Builder<MethodHandle> argumentMethods = ImmutableList.builder(); Type type = boundVariables.getTypeVariable("T"); for (Type parameterType : type.getTypeParameters()) { Signature signature = functionRegistry.resolveOperator(IS_DISTINCT_FROM, ImmutableList.of(parameterType, parameterType)); FunctionInvoker functionInvoker = functionRegistry.getFunctionInvokerProvider().createFunctionInvoker( signature, Optional.of(new InvocationConvention( ImmutableList.of(NULL_FLAG, NULL_FLAG), InvocationConvention.InvocationReturnConvention.FAIL_ON_NULL, false))); argumentMethods.add(functionInvoker.methodHandle()); } return new ScalarFunctionImplementation( ImmutableList.of( new ScalarImplementationChoice( false, ImmutableList.of(valueTypeArgumentProperty(USE_NULL_FLAG), valueTypeArgumentProperty(USE_NULL_FLAG)), METHOD_HANDLE_NULL_FLAG.bindTo(type).bindTo(argumentMethods.build()), Optional.empty()), new ScalarImplementationChoice( false, ImmutableList.of(valueTypeArgumentProperty(BLOCK_AND_POSITION), valueTypeArgumentProperty(BLOCK_AND_POSITION)), METHOD_HANDLE_BLOCK_POSITION.bindTo(type).bindTo(argumentMethods.build()), Optional.empty())), isDeterministic()); }
@Override public ScalarFunctionImplementation specialize(BoundVariables boundVariables, int arity, TypeManager typeManager, FunctionRegistry functionRegistry) { ImmutableList.Builder<MethodHandle> argumentMethods = ImmutableList.builder(); Type type = boundVariables.getTypeVariable("T"); for (Type parameterType : type.getTypeParameters()) { Signature signature = functionRegistry.resolveOperator(IS_DISTINCT_FROM, ImmutableList.of(parameterType, parameterType)); FunctionInvoker functionInvoker = functionRegistry.getFunctionInvokerProvider().createFunctionInvoker( signature, Optional.of(new InvocationConvention( ImmutableList.of(NULL_FLAG, NULL_FLAG), InvocationConvention.InvocationReturnConvention.FAIL_ON_NULL, false))); argumentMethods.add(functionInvoker.methodHandle()); } return new ScalarFunctionImplementation( ImmutableList.of( new ScalarImplementationChoice( false, ImmutableList.of(valueTypeArgumentProperty(USE_NULL_FLAG), valueTypeArgumentProperty(USE_NULL_FLAG)), METHOD_HANDLE_NULL_FLAG.bindTo(type).bindTo(argumentMethods.build()), Optional.empty()), new ScalarImplementationChoice( false, ImmutableList.of(valueTypeArgumentProperty(BLOCK_AND_POSITION), valueTypeArgumentProperty(BLOCK_AND_POSITION)), METHOD_HANDLE_BLOCK_POSITION.bindTo(type).bindTo(argumentMethods.build()), Optional.empty())), isDeterministic()); }