Search in sources :

Example 1 with OutputFunction

use of io.prestosql.spi.function.OutputFunction in project hetu-core by openlookeng.

the class DoubleHistogramAggregation method output.

@OutputFunction("map(double,double)")
public static void output(@AggregationState State state, BlockBuilder out) {
    if (state.get() == null) {
        out.appendNull();
    } else {
        Map<Double, Double> value = state.get().getBuckets();
        BlockBuilder entryBuilder = out.beginBlockEntry();
        for (Map.Entry<Double, Double> entry : value.entrySet()) {
            DoubleType.DOUBLE.writeDouble(entryBuilder, entry.getKey());
            DoubleType.DOUBLE.writeDouble(entryBuilder, entry.getValue());
        }
        out.closeEntry();
    }
}
Also used : Map(java.util.Map) BlockBuilder(io.prestosql.spi.block.BlockBuilder) OutputFunction(io.prestosql.spi.function.OutputFunction)

Example 2 with OutputFunction

use of io.prestosql.spi.function.OutputFunction in project hetu-core by openlookeng.

the class RealHistogramAggregation method output.

@OutputFunction("map(real,real)")
public static void output(@AggregationState DoubleHistogramAggregation.State state, BlockBuilder out) {
    if (state.get() == null) {
        out.appendNull();
    } else {
        Map<Double, Double> value = state.get().getBuckets();
        BlockBuilder entryBuilder = out.beginBlockEntry();
        for (Map.Entry<Double, Double> entry : value.entrySet()) {
            REAL.writeLong(entryBuilder, floatToRawIntBits(entry.getKey().floatValue()));
            REAL.writeLong(entryBuilder, floatToRawIntBits(entry.getValue().floatValue()));
        }
        out.closeEntry();
    }
}
Also used : Map(java.util.Map) BlockBuilder(io.prestosql.spi.block.BlockBuilder) OutputFunction(io.prestosql.spi.function.OutputFunction)

Example 3 with OutputFunction

use of io.prestosql.spi.function.OutputFunction in project hetu-core by openlookeng.

the class ApproximateDoublePercentileAggregations method output.

@OutputFunction(StandardTypes.DOUBLE)
public static void output(@AggregationState DigestAndPercentileState state, BlockBuilder out) {
    QuantileDigest digest = state.getDigest();
    double percentile = state.getPercentile();
    if (digest == null || digest.getCount() == 0.0) {
        out.appendNull();
    } else {
        checkState(percentile != -1.0, "Percentile is missing");
        checkCondition(0 <= percentile && percentile <= 1, INVALID_FUNCTION_ARGUMENT, "Percentile must be between 0 and 1");
        DOUBLE.writeDouble(out, sortableLongToDouble(digest.getQuantile(percentile)));
    }
}
Also used : QuantileDigest(io.airlift.stats.QuantileDigest) OutputFunction(io.prestosql.spi.function.OutputFunction)

Example 4 with OutputFunction

use of io.prestosql.spi.function.OutputFunction in project hetu-core by openlookeng.

the class ApproximateRealPercentileAggregations method output.

@OutputFunction(StandardTypes.REAL)
public static void output(@AggregationState DigestAndPercentileState state, BlockBuilder out) {
    QuantileDigest digest = state.getDigest();
    double percentile = state.getPercentile();
    if (digest == null || digest.getCount() == 0.0) {
        out.appendNull();
    } else {
        checkState(percentile != -1.0, "Percentile is missing");
        checkCondition(0 <= percentile && percentile <= 1, INVALID_FUNCTION_ARGUMENT, "Percentile must be between 0 and 1");
        REAL.writeLong(out, floatToRawIntBits(sortableIntToFloat((int) digest.getQuantile(percentile))));
    }
}
Also used : QuantileDigest(io.airlift.stats.QuantileDigest) OutputFunction(io.prestosql.spi.function.OutputFunction)

Example 5 with OutputFunction

use of io.prestosql.spi.function.OutputFunction in project hetu-core by openlookeng.

the class ApproximateDoublePercentileArrayAggregations method output.

@OutputFunction("array(double)")
public static void output(@AggregationState DigestAndPercentileArrayState state, BlockBuilder out) {
    QuantileDigest digest = state.getDigest();
    List<Double> percentiles = state.getPercentiles();
    if (percentiles == null || digest == null) {
        out.appendNull();
        return;
    }
    BlockBuilder blockBuilder = out.beginBlockEntry();
    for (int i = 0; i < percentiles.size(); i++) {
        Double percentile = percentiles.get(i);
        DOUBLE.writeDouble(blockBuilder, sortableLongToDouble(digest.getQuantile(percentile)));
    }
    out.closeEntry();
}
Also used : QuantileDigest(io.airlift.stats.QuantileDigest) FloatingPointBitsConverterUtil.sortableLongToDouble(io.prestosql.operator.aggregation.FloatingPointBitsConverterUtil.sortableLongToDouble) BlockBuilder(io.prestosql.spi.block.BlockBuilder) OutputFunction(io.prestosql.spi.function.OutputFunction)

Aggregations

OutputFunction (io.prestosql.spi.function.OutputFunction)9 QuantileDigest (io.airlift.stats.QuantileDigest)6 BlockBuilder (io.prestosql.spi.block.BlockBuilder)5 Map (java.util.Map)2 Rectangle (io.prestosql.geospatial.Rectangle)1 FloatingPointBitsConverterUtil.sortableLongToDouble (io.prestosql.operator.aggregation.FloatingPointBitsConverterUtil.sortableLongToDouble)1