Search in sources :

Example 21 with TypeParameter

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();
}
Also used : BlockBuilder(io.prestosql.spi.block.BlockBuilder) TypeParameterSpecialization(io.prestosql.spi.function.TypeParameterSpecialization) TypeParameter(io.prestosql.spi.function.TypeParameter) SqlType(io.prestosql.spi.function.SqlType)

Example 22 with TypeParameter

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());
}
Also used : HyperLogLog(io.airlift.stats.cardinality.HyperLogLog) TypeParameter(io.prestosql.spi.function.TypeParameter) InputFunction(io.prestosql.spi.function.InputFunction)

Example 23 with TypeParameter

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());
}
Also used : HyperLogLog(io.airlift.stats.cardinality.HyperLogLog) TypeParameter(io.prestosql.spi.function.TypeParameter) InputFunction(io.prestosql.spi.function.InputFunction)

Example 24 with TypeParameter

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());
}
Also used : HyperLogLog(io.airlift.stats.cardinality.HyperLogLog) TypeParameter(io.prestosql.spi.function.TypeParameter) InputFunction(io.prestosql.spi.function.InputFunction)

Aggregations

TypeParameter (io.prestosql.spi.function.TypeParameter)24 SqlType (io.prestosql.spi.function.SqlType)20 BlockBuilder (io.prestosql.spi.block.BlockBuilder)18 TypedSet (io.prestosql.operator.aggregation.TypedSet)6 TypeParameterSpecialization (io.prestosql.spi.function.TypeParameterSpecialization)5 Block (io.prestosql.spi.block.Block)4 HyperLogLog (io.airlift.stats.cardinality.HyperLogLog)3 PrestoException (io.prestosql.spi.PrestoException)3 InputFunction (io.prestosql.spi.function.InputFunction)3 ArrayType (io.prestosql.spi.type.ArrayType)3 RowType (io.prestosql.spi.type.RowType)3 Type (io.prestosql.spi.type.Type)3 Slice (io.airlift.slice.Slice)2 SqlNullable (io.prestosql.spi.function.SqlNullable)2 MapType (io.prestosql.spi.type.MapType)2 ImmutableList (com.google.common.collect.ImmutableList)1 ImmutableList.toImmutableList (com.google.common.collect.ImmutableList.toImmutableList)1 DictionaryBlock (io.prestosql.spi.block.DictionaryBlock)1 PageBuilderStatus (io.prestosql.spi.block.PageBuilderStatus)1 OperatorType (io.prestosql.spi.function.OperatorType)1