Examples of QuantileDigest


Examples of io.airlift.stats.QuantileDigest

    }

    @InputFunction
    public static void weightedInput(DigestAndPercentileState state, @SqlType(StandardTypes.BIGINT) long value, @SqlType(StandardTypes.BIGINT) long weight, @SqlType(StandardTypes.DOUBLE) double percentile)
    {
        QuantileDigest digest = state.getDigest();

        if (digest == null) {
            digest = new QuantileDigest(0.01);
            state.setDigest(digest);
            state.addMemoryUsage(digest.estimatedInMemorySizeInBytes());
        }

        state.addMemoryUsage(-digest.estimatedInMemorySizeInBytes());
        digest.add(value, weight);
        state.addMemoryUsage(digest.estimatedInMemorySizeInBytes());

        // use last percentile
        state.setPercentile(percentile);
    }
View Full Code Here

Examples of io.airlift.stats.QuantileDigest

    }

    @CombineFunction
    public static void combine(DigestAndPercentileState state, DigestAndPercentileState otherState)
    {
        QuantileDigest input = otherState.getDigest();

        QuantileDigest previous = state.getDigest();
        if (previous == null) {
            state.setDigest(input);
            state.addMemoryUsage(input.estimatedInMemorySizeInBytes());
        }
        else {
            state.addMemoryUsage(-previous.estimatedInMemorySizeInBytes());
            previous.merge(input);
            state.addMemoryUsage(previous.estimatedInMemorySizeInBytes());
        }
        state.setPercentile(otherState.getPercentile());
    }
View Full Code Here

Examples of io.airlift.stats.QuantileDigest

    }

    @OutputFunction(StandardTypes.BIGINT)
    public static void output(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");
            BIGINT.writeLong(out, digest.getQuantile(percentile));
        }
    }
View Full Code Here

Examples of io.airlift.stats.QuantileDigest

    }

    @OutputFunction(StandardTypes.DOUBLE)
    public static void output(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, longToDouble(digest.getQuantile(percentile)));
        }
    }
View Full Code Here

Examples of io.airlift.stats.QuantileDigest

    private static final int PERCENTILE_INDEX = 2;

    @Override
    public DigestAndPercentile initialize()
    {
        return new DigestAndPercentile(new QuantileDigest(0.01));
    }
View Full Code Here

Examples of io.airlift.stats.QuantileDigest

    public static final DoubleApproximatePercentileAggregation INSTANCE = new DoubleApproximatePercentileAggregation();

    @Override
    public DigestAndPercentile initialize()
    {
        return new DigestAndPercentile(new QuantileDigest(0.01));
    }
View Full Code Here

Examples of io.airlift.stats.QuantileDigest

    private static final int PERCENTILE_INDEX = 2;

    @Override
    public DigestAndPercentile initialize()
    {
        return new DigestAndPercentile(new QuantileDigest(0.01));
    }
View Full Code Here

Examples of io.airlift.stats.QuantileDigest

    public static final LongApproximatePercentileAggregation INSTANCE = new LongApproximatePercentileAggregation();

    @Override
    public DigestAndPercentile initialize()
    {
        return new DigestAndPercentile(new QuantileDigest(0.01));
    }
View Full Code Here

Examples of io.airlift.stats.QuantileDigest

                // skip null values
                if (!values.isNull() && sampleWeight > 0) {
                    DigestAndPercentile currentValue = digests.get(groupId);
                    if (currentValue == null) {
                        currentValue = new DigestAndPercentile(new QuantileDigest(0.01));
                        digests.set(groupId, currentValue);
                        sizeOfValues += currentValue.getDigest().estimatedInMemorySizeInBytes();
                    }

                    sizeOfValues -= currentValue.getDigest().estimatedInMemorySizeInBytes();
View Full Code Here

Examples of io.airlift.stats.QuantileDigest

                if (!intermediates.isNull()) {
                    long groupId = groupIdsBlock.getGroupId(position);

                    DigestAndPercentile currentValue = digests.get(groupId);
                    if (currentValue == null) {
                        currentValue = new DigestAndPercentile(new QuantileDigest(0.01));
                        digests.set(groupId, currentValue);
                        sizeOfValues += currentValue.getDigest().estimatedInMemorySizeInBytes();
                    }

                    SliceInput input = intermediates.getSlice().getInput();
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.