@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); }
@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); }
@TypeParameter("T") @SqlType(StandardTypes.BIGINT) public static long hash( @OperatorDependency(operator = HASH_CODE, returnType = StandardTypes.BIGINT, argumentTypes = {"T"}) MethodHandle hashFunction, @TypeParameter("T") Type type, @SqlType("array(T)") Block block) { try { long hash = 0; for (int i = 0; i < block.getPositionCount(); i++) { hash = CombineHashFunction.getHash(hash, block.isNull(i) ? NULL_HASH_CODE : (long) hashFunction.invoke(readNativeValue(type, block, i))); } return hash; } catch (Throwable t) { throw internalError(t); } }
@TypeParameter("T") @SqlType(StandardTypes.BIGINT) public static long arrayPosition( @TypeParameter("T") Type type, @OperatorDependency(operator = EQUAL, returnType = StandardTypes.BOOLEAN, argumentTypes = {"T", "T"}) MethodHandle equalMethodHandle, @SqlType("array(T)") Block array, @SqlType("T") long element) { int size = array.getPositionCount(); for (int i = 0; i < size; i++) { if (!array.isNull(i)) { long arrayValue = type.getLong(array, i); try { Boolean result = (Boolean) equalMethodHandle.invokeExact(arrayValue, element); checkNotIndeterminate(result); if (result) { return i + 1; // result is 1-based (instead of 0) } } catch (Throwable t) { throw internalError(t); } } } return 0; }
@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); }
@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); }
@TypeParameter("T") @SqlType(StandardTypes.BIGINT) public static long arrayPosition( @TypeParameter("T") Type type, @OperatorDependency(operator = EQUAL, returnType = StandardTypes.BOOLEAN, argumentTypes = {"T", "T"}) MethodHandle equalMethodHandle, @SqlType("array(T)") Block array, @SqlType("T") Slice element) { int size = array.getPositionCount(); for (int i = 0; i < size; i++) { if (!array.isNull(i)) { Slice arrayValue = type.getSlice(array, i); try { Boolean result = (Boolean) equalMethodHandle.invokeExact(arrayValue, element); checkNotIndeterminate(result); if (result) { return i + 1; // result is 1-based (instead of 0) } } catch (Throwable t) { throw internalError(t); } } } return 0; }
@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; } }
@InputFunction public static void input( @OperatorDependency(operator = LESS_THAN, returnType = StandardTypes.BOOLEAN, argumentTypes = {DOUBLE, DOUBLE}) MethodHandle methodHandle, @AggregationState NullableDoubleState state, @SqlType(DOUBLE) double value) { // noop this is only for annotation testing puproses }
@TypeParameter("T") @SqlType(StandardTypes.BIGINT) public static long arrayPosition( @TypeParameter("T") Type type, @OperatorDependency(operator = EQUAL, returnType = StandardTypes.BOOLEAN, argumentTypes = {"T", "T"}) MethodHandle equalMethodHandle, @SqlType("array(T)") Block array, @SqlType("T") boolean element) { int size = array.getPositionCount(); for (int i = 0; i < size; i++) { if (!array.isNull(i)) { boolean arrayValue = type.getBoolean(array, i); try { Boolean result = (Boolean) equalMethodHandle.invokeExact(arrayValue, element); checkNotIndeterminate(result); if (result) { return i + 1; // result is 1-based (instead of 0) } } catch (Throwable t) { throw internalError(t); } } } return 0; }
@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("T") @SqlType(StandardTypes.BIGINT) public static long arrayPosition( @TypeParameter("T") Type type, @OperatorDependency(operator = EQUAL, returnType = StandardTypes.BOOLEAN, argumentTypes = {"T", "T"}) MethodHandle equalMethodHandle, @SqlType("array(T)") Block array, @SqlType("T") double element) { int size = array.getPositionCount(); for (int i = 0; i < size; i++) { if (!array.isNull(i)) { double arrayValue = type.getDouble(array, i); try { Boolean result = (Boolean) equalMethodHandle.invokeExact(arrayValue, element); checkNotIndeterminate(result); if (result) { return i + 1; // result is 1-based (instead of 0) } } catch (Throwable t) { throw internalError(t); } } } return 0; }
@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(StandardTypes.BIGINT) public static long arrayPosition( @TypeParameter("T") Type type, @OperatorDependency(operator = EQUAL, returnType = StandardTypes.BOOLEAN, argumentTypes = {"T", "T"}) MethodHandle equalMethodHandle, @SqlType("array(T)") Block array, @SqlType("T") Block element) { int size = array.getPositionCount(); for (int i = 0; i < size; i++) { if (!array.isNull(i)) { Object arrayValue = type.getObject(array, i); try { Boolean result = (Boolean) equalMethodHandle.invoke(arrayValue, element); checkNotIndeterminate(result); if (result) { return i + 1; // result is 1-based (instead of 0) } } catch (Throwable t) { throw internalError(t); } } } return 0; }
@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") @TypeParameterSpecialization(name = "T", nativeContainerType = long.class) @SqlType(StandardTypes.BIGINT) public static long hashLong( @OperatorDependency(operator = HASH_CODE, returnType = StandardTypes.BIGINT, argumentTypes = {"T"}) MethodHandle hashFunction, @TypeParameter("T") Type type, @SqlType("array(T)") Block block) { try { long hash = 0; for (int i = 0; i < block.getPositionCount(); i++) { hash = CombineHashFunction.getHash(hash, block.isNull(i) ? NULL_HASH_CODE : (long) hashFunction.invokeExact(type.getLong(block, i))); } return hash; } catch (Throwable t) { throw internalError(t); } }
@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") @TypeParameterSpecialization(name = "T", nativeContainerType = boolean.class) @SqlType(StandardTypes.BIGINT) public static long hashBoolean( @OperatorDependency(operator = HASH_CODE, returnType = StandardTypes.BIGINT, argumentTypes = {"T"}) MethodHandle hashFunction, @TypeParameter("T") Type type, @SqlType("array(T)") Block block) { try { long hash = 0; for (int i = 0; i < block.getPositionCount(); i++) { hash = CombineHashFunction.getHash(hash, block.isNull(i) ? NULL_HASH_CODE : (long) hashFunction.invokeExact(type.getBoolean(block, i))); } return hash; } catch (Throwable t) { throw internalError(t); } }
@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") @TypeParameterSpecialization(name = "T", nativeContainerType = Slice.class) @SqlType(StandardTypes.BIGINT) public static long hashSlice( @OperatorDependency(operator = HASH_CODE, returnType = StandardTypes.BIGINT, argumentTypes = {"T"}) MethodHandle hashFunction, @TypeParameter("T") Type type, @SqlType("array(T)") Block block) { try { long hash = 0; for (int i = 0; i < block.getPositionCount(); i++) { hash = CombineHashFunction.getHash(hash, block.isNull(i) ? NULL_HASH_CODE : (long) hashFunction.invokeExact(type.getSlice(block, i))); } return hash; } catch (Throwable t) { throw internalError(t); } }