use of io.trino.sql.gen.VarArgsToArrayAdapterGenerator.MethodHandleAndConstructor in project trino by trinodb.
the class MapConcatFunction method specialize.
@Override
protected ScalarFunctionImplementation specialize(BoundSignature boundSignature) {
if (boundSignature.getArity() < 2) {
throw new TrinoException(INVALID_FUNCTION_ARGUMENT, "There must be two or more concatenation arguments to " + FUNCTION_NAME);
}
MapType mapType = (MapType) boundSignature.getReturnType();
Type keyType = mapType.getKeyType();
BlockPositionEqual keyEqual = blockTypeOperators.getEqualOperator(keyType);
BlockPositionHashCode keyHashCode = blockTypeOperators.getHashCodeOperator(keyType);
MethodHandleAndConstructor methodHandleAndConstructor = generateVarArgsToArrayAdapter(Block.class, Block.class, boundSignature.getArity(), MethodHandles.insertArguments(METHOD_HANDLE, 0, mapType, keyEqual, keyHashCode), USER_STATE_FACTORY.bindTo(mapType));
return new ChoicesScalarFunctionImplementation(boundSignature, FAIL_ON_NULL, nCopies(boundSignature.getArity(), NEVER_NULL), methodHandleAndConstructor.getMethodHandle(), Optional.of(methodHandleAndConstructor.getConstructor()));
}
Aggregations