Search in sources :

Example 1 with VarArgMethodHandle

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());
}
Also used : MapType(com.facebook.presto.common.type.MapType) Type(com.facebook.presto.common.type.Type) VarArgMethodHandle(com.facebook.presto.sql.gen.VarArgsToArrayAdapterGenerator.VarArgMethodHandle) PrestoException(com.facebook.presto.spi.PrestoException) MapType(com.facebook.presto.common.type.MapType)

Aggregations

MapType (com.facebook.presto.common.type.MapType)1 Type (com.facebook.presto.common.type.Type)1 PrestoException (com.facebook.presto.spi.PrestoException)1 VarArgMethodHandle (com.facebook.presto.sql.gen.VarArgsToArrayAdapterGenerator.VarArgMethodHandle)1