@TypeParameter("K") @TypeParameter("V") @SqlType(StandardTypes.BIGINT) public static long mapCardinality(@SqlType("map(K,V)") Block block) { return block.getPositionCount() / 2; } }
@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") double value) { return remove(equalsFunction, type, array, (Object) value); }
@TypeParameter("K") @TypeParameter("V") @SqlType(StandardTypes.BOOLEAN) public static boolean indeterminate( @OperatorDependency(operator = INDETERMINATE, returnType = StandardTypes.BOOLEAN, argumentTypes = {"V"}) MethodHandle valueIndeterminateFunction, @TypeParameter("K") Type keyType, @TypeParameter("V") Type valueType, @SqlType("map(K,V)") Block block, @IsNull boolean isNull) { if (isNull) { return true; } for (int i = 0; i < block.getPositionCount(); i += 2) { // since maps are not allowed to have indeterminate keys we only check values here if (block.isNull(i + 1)) { return true; } try { if ((boolean) valueIndeterminateFunction.invoke(readNativeValue(valueType, block, i + 1), false)) { return true; } } catch (Throwable t) { throw internalError(t); } } return false; } }
@TypeParameter("E") @SqlNullable @SqlType("E") public static Slice sliceElementAt(@TypeParameter("E") Type elementType, @SqlType("array(E)") Block array, @SqlType("bigint") long index) { int position = checkedIndexToBlockPosition(array, index); if (position == -1) { return null; } if (array.isNull(position)) { return null; } return elementType.getSlice(array, position); }
@TypeParameter("T") @SqlType(StandardTypes.VARCHAR) public static Slice typeof( @TypeParameter("T") Type type, @SqlNullable @SqlType("T") Long value) { return typeof(type, (Object) value); }
@TypeParameter("K") @TypeParameter("V") @SqlType(StandardTypes.BIGINT) public long good1( @TypeParameter("MAP(K,V)") Type type, @SqlType(StandardTypes.BIGINT) long value) { return value; } }
@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("E") @SqlType(StandardTypes.BIGINT) public static long arrayCardinality(@SqlType("array(E)") Block block) { return block.getPositionCount(); } }
@TypeParameter("E") @SqlNullable @SqlType("E") public static Boolean booleanElementAt(@TypeParameter("E") Type elementType, @SqlType("array(E)") Block array, @SqlType("bigint") long index) { int position = checkedIndexToBlockPosition(array, index); if (position == -1) { return null; } if (array.isNull(position)) { return null; } return elementType.getBoolean(array, position); }
@TypeParameter("T") @SqlType(StandardTypes.VARCHAR) public static Slice typeof( @TypeParameter("T") Type type, @SqlNullable @SqlType("T") Double value) { return typeof(type, (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("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("E") @SqlType("E") public static long specializedSlice(@TypeParameter("E") Type type, @SqlType("E") long input) { return input; } }
@TypeParameter("T") @SqlType(StandardTypes.BOOLEAN) @SqlNullable public static Boolean contains( @TypeParameter("T") Type elementType, @OperatorDependency(operator = EQUAL, returnType = StandardTypes.BOOLEAN, argumentTypes = {"T", "T"}) MethodHandle equals, @SqlType("array(T)") Block arrayBlock, @SqlType("T") Block value) for (int i = 0; i < arrayBlock.getPositionCount(); i++) { if (arrayBlock.isNull(i)) { foundNull = true; continue;
@TypeParameter("K") @TypeParameter("V") @SqlType("array(K)") public static Block getKeys( @TypeParameter("K") Type keyType, @SqlType("map(K,V)") Block block) { BlockBuilder blockBuilder = keyType.createBlockBuilder(null, block.getPositionCount() / 2); for (int i = 0; i < block.getPositionCount(); i += 2) { keyType.appendTo(block, i, blockBuilder); } return blockBuilder.build(); } }
@TypeParameter("E") @SqlNullable @SqlType("E") public static Long longElementAt(@TypeParameter("E") Type elementType, @SqlType("array(E)") Block array, @SqlType("bigint") long index) { int position = checkedIndexToBlockPosition(array, index); if (position == -1) { return null; } if (array.isNull(position)) { return null; } return elementType.getLong(array, position); }
@TypeParameter("T") @SqlType(StandardTypes.VARCHAR) public static Slice typeof( @TypeParameter("T") Type type, @SqlNullable @SqlType("T") Boolean value) { return typeof(type, (Object) value); } }
@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); }
@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); }