use of io.trino.spi.function.OperatorMethodHandle in project trino by trinodb.
the class TypeOperators method adaptNeverNullEqualToDistinctFrom.
private static OperatorMethodHandle adaptNeverNullEqualToDistinctFrom(MethodHandle neverNullEqual) {
// boolean distinctFrom(T left, boolean leftIsNull, T right, boolean rightIsNull)
// {
// if (leftIsNull || rightIsNull) {
// return leftIsNull ^ rightIsNull;
// }
// return notEqual(equalOperator.invokeExact(left, leftIsNull, right, rightIsNull));
// }
MethodHandle eitherArgIsNull = LOGICAL_OR;
eitherArgIsNull = dropArguments(eitherArgIsNull, 0, neverNullEqual.type().parameterType(0));
eitherArgIsNull = dropArguments(eitherArgIsNull, 2, neverNullEqual.type().parameterType(1));
MethodHandle distinctNullValues = LOGICAL_XOR;
distinctNullValues = dropArguments(distinctNullValues, 0, neverNullEqual.type().parameterType(0));
distinctNullValues = dropArguments(distinctNullValues, 2, neverNullEqual.type().parameterType(1));
MethodHandle notEqual = filterReturnValue(neverNullEqual, NOT_EQUAL);
notEqual = dropArguments(notEqual, 1, boolean.class);
notEqual = dropArguments(notEqual, 3, boolean.class);
return new OperatorMethodHandle(simpleConvention(FAIL_ON_NULL, NULL_FLAG, NULL_FLAG), guardWithTest(eitherArgIsNull, distinctNullValues, notEqual));
}
use of io.trino.spi.function.OperatorMethodHandle in project trino by trinodb.
the class TypeOperators method adaptNeverNullComparisonToOrdering.
//
// Adapt comparison to ordering
//
private static OperatorMethodHandle adaptNeverNullComparisonToOrdering(SortOrder sortOrder, MethodHandle neverNullComparison) {
MethodType finalSignature = MethodType.methodType(int.class, boolean.class, neverNullComparison.type().parameterType(0), boolean.class, neverNullComparison.type().parameterType(1));
// (leftIsNull, rightIsNull, leftValue, rightValue)::int
MethodHandle order = adaptComparisonToOrdering(sortOrder, neverNullComparison);
// (leftIsNull, leftValue, rightIsNull, rightValue)::int
order = permuteArguments(order, finalSignature, 0, 2, 1, 3);
return new OperatorMethodHandle(simpleConvention(FAIL_ON_NULL, NULL_FLAG, NULL_FLAG), order);
}
use of io.trino.spi.function.OperatorMethodHandle in project trino by trinodb.
the class TypeOperators method adaptBlockPositionComparisonToOrdering.
private static OperatorMethodHandle adaptBlockPositionComparisonToOrdering(SortOrder sortOrder, MethodHandle blockPositionComparison) {
MethodType finalSignature = MethodType.methodType(int.class, Block.class, int.class, Block.class, int.class);
// (leftIsNull, rightIsNull, leftBlock, leftPosition, rightBlock, rightPosition)::int
MethodHandle order = adaptComparisonToOrdering(sortOrder, blockPositionComparison);
// (leftBlock, leftPosition, rightBlock, rightPosition, leftBlock, leftPosition, rightBlock, rightPosition)::int
order = collectArguments(order, 1, BLOCK_IS_NULL);
order = collectArguments(order, 0, BLOCK_IS_NULL);
// (leftBlock, leftPosition, rightBlock, rightPosition)::int
order = permuteArguments(order, finalSignature, 0, 1, 2, 3, 0, 1, 2, 3);
return new OperatorMethodHandle(simpleConvention(FAIL_ON_NULL, BLOCK_POSITION, BLOCK_POSITION), order);
}
Aggregations