use of io.prestosql.spi.function.TypeParameter in project hetu-core by openlookeng.
the class ArrayFilterFunction method filterDouble.
@TypeParameter("T")
@TypeParameterSpecialization(name = "T", nativeContainerType = double.class)
@SqlType("array(T)")
public static Block filterDouble(@TypeParameter("T") Type elementType, @SqlType("array(T)") Block arrayBlock, @SqlType("function(T, boolean)") FilterDoubleLambda function) {
int positionCount = arrayBlock.getPositionCount();
BlockBuilder resultBuilder = elementType.createBlockBuilder(null, positionCount);
for (int position = 0; position < positionCount; position++) {
Double input = null;
if (!arrayBlock.isNull(position)) {
input = elementType.getDouble(arrayBlock, position);
}
Boolean keep = function.apply(input);
if (TRUE.equals(keep)) {
elementType.appendTo(arrayBlock, position, resultBuilder);
}
}
return resultBuilder.build();
}
use of io.prestosql.spi.function.TypeParameter in project hetu-core by openlookeng.
the class ApproximateCountDistinctAggregation method input.
@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, @SqlType(StandardTypes.DOUBLE) double maxStandardError) {
HyperLogLog hll = getOrCreateHyperLogLog(state, maxStandardError);
state.addMemoryUsage(-hll.estimatedInMemorySize());
long hash;
try {
hash = (long) methodHandle.invokeExact(value);
} catch (Throwable t) {
throw internalError(t);
}
hll.addHash(hash);
state.addMemoryUsage(hll.estimatedInMemorySize());
}
use of io.prestosql.spi.function.TypeParameter in project hetu-core by openlookeng.
the class ApproximateCountDistinctAggregation method input.
@InputFunction
@TypeParameter("T")
public static void input(@OperatorDependency(operator = XX_HASH_64, returnType = StandardTypes.BIGINT, argumentTypes = { "T" }) MethodHandle methodHandle, @AggregationState HyperLogLogState state, @SqlType("T") long value, @SqlType(StandardTypes.DOUBLE) double maxStandardError) {
HyperLogLog hll = getOrCreateHyperLogLog(state, maxStandardError);
state.addMemoryUsage(-hll.estimatedInMemorySize());
long hash;
try {
hash = (long) methodHandle.invokeExact(value);
} catch (Throwable t) {
throw internalError(t);
}
hll.addHash(hash);
state.addMemoryUsage(hll.estimatedInMemorySize());
}
use of io.prestosql.spi.function.TypeParameter in project hetu-core by openlookeng.
the class ApproximateCountDistinctAggregation method input.
@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, @SqlType(StandardTypes.DOUBLE) double maxStandardError) {
HyperLogLog hll = getOrCreateHyperLogLog(state, maxStandardError);
state.addMemoryUsage(-hll.estimatedInMemorySize());
long hash;
try {
hash = (long) methodHandle.invokeExact(value);
} catch (Throwable t) {
throw internalError(t);
}
hll.addHash(hash);
state.addMemoryUsage(hll.estimatedInMemorySize());
}
Aggregations