@TypeParameter("K") @TypeParameter("V") @SqlNullable @SqlType(StandardTypes.BOOLEAN) public static Boolean notEqual( @OperatorDependency(operator = EQUAL, returnType = StandardTypes.BOOLEAN, argumentTypes = {"K", "K"}) MethodHandle keyEqualsFunction, @OperatorDependency(operator = HASH_CODE, returnType = StandardTypes.BIGINT, argumentTypes = {"K"}) MethodHandle keyHashcodeFunction, @OperatorDependency(operator = EQUAL, returnType = StandardTypes.BOOLEAN, argumentTypes = {"V", "V"}) MethodHandle valueEqualsFunction, @TypeParameter("K") Type keyType, @TypeParameter("V") Type valueType, @SqlType("map(K,V)") Block left, @SqlType("map(K,V)") Block right) { Boolean equals = MapEqualOperator.equals(keyEqualsFunction, keyHashcodeFunction, valueEqualsFunction, keyType, valueType, left, right); if (equals == null) { return null; } return !equals; } }
public static ImplementationDependency createDependency(Annotation annotation, Set<String> literalParameters) { if (annotation instanceof TypeParameter) { return new TypeImplementationDependency(((TypeParameter) annotation).value()); } if (annotation instanceof LiteralParameter) { return new LiteralImplementationDependency(((LiteralParameter) annotation).value()); } if (annotation instanceof FunctionDependency) { FunctionDependency functionDependency = (FunctionDependency) annotation; return new FunctionImplementationDependency( functionDependency.name(), parseTypeSignature(functionDependency.returnType(), literalParameters), Arrays.stream(functionDependency.argumentTypes()) .map(signature -> parseTypeSignature(signature, literalParameters)) .collect(toImmutableList()), toInvocationConvention(functionDependency.convention())); } if (annotation instanceof OperatorDependency) { OperatorDependency operatorDependency = (OperatorDependency) annotation; return new OperatorImplementationDependency( operatorDependency.operator(), parseTypeSignature(operatorDependency.returnType(), literalParameters), Arrays.stream(operatorDependency.argumentTypes()) .map(signature -> parseTypeSignature(signature, literalParameters)) .collect(toImmutableList()), toInvocationConvention(operatorDependency.convention())); } throw new IllegalArgumentException("Unsupported annotation " + annotation.getClass().getSimpleName()); }
@InputFunction @TypeParameter("T") public static void input( @OperatorDependency(operator = XX_HASH_64, returnType = StandardTypes.BIGINT, argumentTypes = {"T"}) MethodHandle methodHandle, @AggregationState HyperLogLogState state, @SqlType("T") Slice value) { ApproximateCountDistinctAggregation.input(methodHandle, state, value, DEFAULT_STANDARD_ERROR); }
@OutputFunction(DOUBLE) public static void output( @OperatorDependency(operator = LESS_THAN, returnType = StandardTypes.BOOLEAN, argumentTypes = {DOUBLE, DOUBLE}) MethodHandle methodHandle, @AggregationState NullableDoubleState state, BlockBuilder out) { // noop this is only for annotation testing puproses }
@InputFunction @TypeParameter("T") public static void input( @OperatorDependency(operator = XX_HASH_64, returnType = StandardTypes.BIGINT, argumentTypes = {"T"}) MethodHandle methodHandle, @AggregationState HyperLogLogState state, @SqlType("T") double value) { ApproximateCountDistinctAggregation.input(methodHandle, state, value, DEFAULT_STANDARD_ERROR); }
@SqlNullable @SqlType(StandardTypes.BOOLEAN) public Boolean arraysOverlapInt( @OperatorDependency(operator = LESS_THAN, returnType = StandardTypes.BOOLEAN, argumentTypes = {"integer", "integer"}) MethodHandle lessThanFunction, @SqlType("array(integer)") Block leftArray, @SqlType("array(integer)") Block rightArray) { return genericArraysOverlap(leftArray, rightArray, INTEGER); }
@SqlNullable @SqlType(StandardTypes.BOOLEAN) public Boolean arraysOverlapBigInt( @OperatorDependency(operator = LESS_THAN, returnType = StandardTypes.BOOLEAN, argumentTypes = {"bigint", "bigint"}) MethodHandle lessThanFunction, @SqlType("array(bigint)") Block leftArray, @SqlType("array(bigint)") Block rightArray) { return genericArraysOverlap(leftArray, rightArray, BIGINT); }
@AggregationStateSerializerFactory(NullableDoubleState.class) public static CustomStateSerializerAggregationFunction.CustomSerializer createSerializer( @OperatorDependency(operator = LESS_THAN, returnType = StandardTypes.BOOLEAN, argumentTypes = {DOUBLE, DOUBLE}) MethodHandle methodHandle) { return new CustomStateSerializerAggregationFunction.CustomSerializer(); } }
@TypeParameter("E") @SqlType("array(E)") public Block remove( @OperatorDependency(operator = EQUAL, returnType = StandardTypes.BOOLEAN, argumentTypes = {"E", "E"}) MethodHandle equalsFunction, @TypeParameter("E") Type type, @SqlType("array(E)") Block array, @SqlType("E") double value) { return remove(equalsFunction, type, array, (Object) value); }
@TypeParameter("T") @SqlType("T") @SqlNullable public static Slice sliceArrayMin( @OperatorDependency(operator = LESS_THAN, returnType = StandardTypes.BOOLEAN, argumentTypes = {"T", "T"}) MethodHandle compareMethodHandle, @TypeParameter("T") Type elementType, @SqlType("array(T)") Block block) { return sliceArrayMinMax(compareMethodHandle, elementType, block); }
@TypeParameter("E") @SqlType("array(E)") public Block remove( @OperatorDependency(operator = EQUAL, returnType = StandardTypes.BOOLEAN, argumentTypes = {"E", "E"}) MethodHandle equalsFunction, @TypeParameter("E") Type type, @SqlType("array(E)") Block array, @SqlType("E") boolean value) { return remove(equalsFunction, type, array, (Object) value); }
@TypeParameter("T") @SqlType("T") @SqlNullable public static Long longArrayMax( @OperatorDependency(operator = GREATER_THAN, returnType = StandardTypes.BOOLEAN, argumentTypes = {"T", "T"}) MethodHandle compareMethodHandle, @TypeParameter("T") Type elementType, @SqlType("array(T)") Block block) { return longArrayMinMax(compareMethodHandle, elementType, block); }
@TypeParameter("T") @SqlType("T") @SqlNullable public static Long longArrayMin( @OperatorDependency(operator = LESS_THAN, returnType = StandardTypes.BOOLEAN, argumentTypes = {"T", "T"}) MethodHandle compareMethodHandle, @TypeParameter("T") Type elementType, @SqlType("array(T)") Block block) { return longArrayMinMax(compareMethodHandle, elementType, block); }
@TypeParameter("T") @SqlType("T") @SqlNullable public static Double doubleArrayMin( @OperatorDependency(operator = LESS_THAN, returnType = StandardTypes.BOOLEAN, argumentTypes = {"T", "T"}) MethodHandle compareMethodHandle, @TypeParameter("T") Type elementType, @SqlType("array(T)") Block block) { return doubleArrayMinMax(compareMethodHandle, elementType, block); }
@TypeParameter("T") @SqlType("T") @SqlNullable public static Boolean booleanArrayMax( @OperatorDependency(operator = GREATER_THAN, returnType = StandardTypes.BOOLEAN, argumentTypes = {"T", "T"}) MethodHandle compareMethodHandle, @TypeParameter("T") Type elementType, @SqlType("array(T)") Block block) { return booleanArrayMinMax(compareMethodHandle, elementType, block); }
@TypeParameter("T") @SqlType("T") @SqlNullable public static Double doubleArrayMax( @OperatorDependency(operator = GREATER_THAN, returnType = StandardTypes.BOOLEAN, argumentTypes = {"T", "T"}) MethodHandle compareMethodHandle, @TypeParameter("T") Type elementType, @SqlType("array(T)") Block block) { return doubleArrayMinMax(compareMethodHandle, elementType, block); }
@TypeParameter("T") @SqlType("T") @SqlNullable public static Slice sliceArrayMax( @OperatorDependency(operator = GREATER_THAN, returnType = StandardTypes.BOOLEAN, argumentTypes = {"T", "T"}) MethodHandle compareMethodHandle, @TypeParameter("T") Type elementType, @SqlType("array(T)") Block block) { return sliceArrayMinMax(compareMethodHandle, elementType, block); }
@TypeParameter("T") @SqlType("T") @SqlNullable public static Boolean booleanArrayMin( @OperatorDependency(operator = LESS_THAN, returnType = StandardTypes.BOOLEAN, argumentTypes = {"T", "T"}) MethodHandle compareMethodHandle, @TypeParameter("T") Type elementType, @SqlType("array(T)") Block block) { return booleanArrayMinMax(compareMethodHandle, elementType, block); }
@TypeParameter("K") @TypeParameter("V") @SqlNullable @SqlType(StandardTypes.BOOLEAN) public static Boolean equals( @OperatorDependency(operator = EQUAL, returnType = StandardTypes.BOOLEAN, argumentTypes = {"K", "K"}) MethodHandle keyEqualsFunction, @OperatorDependency(operator = HASH_CODE, returnType = StandardTypes.BIGINT, argumentTypes = {"K"}) MethodHandle keyHashcodeFunction, @OperatorDependency(operator = EQUAL, returnType = StandardTypes.BOOLEAN, argumentTypes = {"V", "V"}) MethodHandle valueEqualsFunction, @TypeParameter("K") Type keyType, @TypeParameter("V") Type valueType, @SqlType("map(K,V)") Block leftMapBlock, @SqlType("map(K,V)") Block rightMapBlock) { return MapGenericEquality.genericEqual( keyType, leftMapBlock, rightMapBlock, (leftMapIndex, rightMapIndex) -> { Object leftValue = readNativeValue(valueType, leftMapBlock, leftMapIndex); if (leftValue == null) { return null; } Object rightValue = readNativeValue(valueType, rightMapBlock, rightMapIndex); if (rightValue == null) { return null; } return (Boolean) valueEqualsFunction.invoke(leftValue, rightValue); }); } }
@CombineFunction public static void combine( @OperatorDependency(operator = LESS_THAN, returnType = StandardTypes.BOOLEAN, argumentTypes = {DOUBLE, DOUBLE}) MethodHandle methodHandle, @AggregationState NullableDoubleState combine1, @AggregationState NullableDoubleState combine2) { // noop this is only for annotation testing puproses }