use of io.trino.spi.function.InvocationConvention.InvocationArgumentConvention.BLOCK_POSITION in project trino by trinodb.
the class RowType method getIndeterminateOperatorInvokers.
private static List<OperatorMethodHandle> getIndeterminateOperatorInvokers(TypeOperators typeOperators, List<Field> fields) {
boolean comparable = fields.stream().allMatch(field -> field.getType().isComparable());
if (!comparable) {
return emptyList();
}
// for large rows, use a generic loop with a megamorphic call site
if (fields.size() > MEGAMORPHIC_FIELD_COUNT) {
List<MethodHandle> indeterminateOperators = fields.stream().map(field -> typeOperators.getIndeterminateOperator(field.getType(), simpleConvention(FAIL_ON_NULL, BLOCK_POSITION))).collect(toUnmodifiableList());
return singletonList(new OperatorMethodHandle(INDETERMINATE_CONVENTION, INDETERMINATE.bindTo(indeterminateOperators)));
}
// (Block):long
MethodHandle indeterminate = dropArguments(constant(boolean.class, false), 0, Block.class);
for (int fieldId = 0; fieldId < fields.size(); fieldId++) {
Field field = fields.get(fieldId);
// (Block, int, MethodHandle, Block):boolean
indeterminate = collectArguments(CHAIN_INDETERMINATE, 0, indeterminate);
// field indeterminate
MethodHandle fieldIndeterminateOperator = typeOperators.getIndeterminateOperator(field.getType(), simpleConvention(FAIL_ON_NULL, BLOCK_POSITION));
// (Block, Block):boolean
indeterminate = insertArguments(indeterminate, 1, fieldId, fieldIndeterminateOperator);
// (Block):boolean
indeterminate = permuteArguments(indeterminate, methodType(boolean.class, Block.class), 0, 0);
}
return singletonList(new OperatorMethodHandle(INDETERMINATE_CONVENTION, indeterminate));
}
Aggregations