use of com.facebook.presto.sql.gen.VarArgsToArrayAdapterGenerator.VarArgMethodHandle in project presto by prestodb.
the class MapConcatFunction method specialize.
@Override
public BuiltInScalarFunctionImplementation specialize(BoundVariables boundVariables, int arity, FunctionAndTypeManager functionAndTypeManager) {
if (arity < 2) {
throw new PrestoException(INVALID_FUNCTION_ARGUMENT, "There must be two or more concatenation arguments to " + FUNCTION_NAME);
}
Type keyType = boundVariables.getTypeVariable("K");
Type valueType = boundVariables.getTypeVariable("V");
MapType mapType = (MapType) functionAndTypeManager.getParameterizedType(StandardTypes.MAP, ImmutableList.of(TypeSignatureParameter.of(keyType.getTypeSignature()), TypeSignatureParameter.of(valueType.getTypeSignature())));
VarArgMethodHandle varArgMethodHandle = generateVarArgsToArrayAdapter(Block.class, Block.class, arity, METHOD_HANDLE.bindTo(mapType));
return new BuiltInScalarFunctionImplementation(false, nCopies(arity, valueTypeArgumentProperty(RETURN_NULL_ON_NULL)), varArgMethodHandle.getMethodHandle());
}
Aggregations