Examples of HyperLogLog


Examples of io.airlift.stats.cardinality.HyperLogLog

            }
        }

        private void add(BlockCursor cursor)
        {
            HyperLogLog instance = HyperLogLog.newInstance(cursor.getSlice());

            if (estimator == null) {
                estimator = instance;
            }
            else {
View Full Code Here

Examples of io.airlift.stats.cardinality.HyperLogLog

        }

        @Override
        public void evaluateFinal(int groupId, BlockBuilder output)
        {
            HyperLogLog estimator = estimators.get(groupId);
            if (estimator == null) {
                output.appendNull();
            }
            else {
                output.appendSlice(estimator.serialize());
            }
        }
View Full Code Here

Examples of io.airlift.stats.cardinality.HyperLogLog

            }
        }

        private void add(long groupId, BlockCursor cursor)
        {
            HyperLogLog instance = HyperLogLog.newInstance(cursor.getSlice());

            HyperLogLog previous = estimators.get(groupId);
            if (previous == null) {
                estimators.set(groupId, instance);
                sizeOfValues += instance.estimatedInMemorySize();
            }
            else {
                sizeOfValues -= previous.estimatedInMemorySize();
                previous.mergeWith(instance);
                sizeOfValues += previous.estimatedInMemorySize();
            }
        }
View Full Code Here

Examples of io.airlift.stats.cardinality.HyperLogLog

    @InputFunction
    @IntermediateInputFunction
    public static void merge(HyperLogLogState state, @SqlType(HyperLogLogType.class) Slice value)
    {
        HyperLogLog input = HyperLogLog.newInstance(value);

        HyperLogLog previous = state.getHyperLogLog();
        if (previous == null) {
            state.setHyperLogLog(input);
            state.addMemoryUsage(input.estimatedInMemorySize());
        }
        else {
            state.addMemoryUsage(-previous.estimatedInMemorySize());
            previous.mergeWith(input);
            state.addMemoryUsage(previous.estimatedInMemorySize());
        }
    }
View Full Code Here

Examples of io.airlift.stats.cardinality.HyperLogLog

    private ApproximateSetAggregation() {}

    @InputFunction
    public static void input(HyperLogLogState state, @SqlType(DoubleType.class) double value)
    {
        HyperLogLog hll = getOrCreateHyperLogLog(state);
        state.addMemoryUsage(-hll.estimatedInMemorySize());
        hll.add(Double.doubleToLongBits(value));
        state.addMemoryUsage(hll.estimatedInMemorySize());
    }
View Full Code Here

Examples of io.airlift.stats.cardinality.HyperLogLog

    }

    @InputFunction
    public static void input(HyperLogLogState state, @SqlType(VarcharType.class) Slice value)
    {
        HyperLogLog hll = getOrCreateHyperLogLog(state);
        state.addMemoryUsage(-hll.estimatedInMemorySize());
        hll.add(value);
        state.addMemoryUsage(hll.estimatedInMemorySize());
    }
View Full Code Here

Examples of io.airlift.stats.cardinality.HyperLogLog

    }

    @InputFunction
    public static void input(HyperLogLogState state, @SqlType(BigintType.class) long value)
    {
        HyperLogLog hll = getOrCreateHyperLogLog(state);
        state.addMemoryUsage(-hll.estimatedInMemorySize());
        hll.add(value);
        state.addMemoryUsage(hll.estimatedInMemorySize());
    }
View Full Code Here

Examples of io.airlift.stats.cardinality.HyperLogLog

        state.addMemoryUsage(hll.estimatedInMemorySize());
    }

    private static HyperLogLog getOrCreateHyperLogLog(HyperLogLogState state)
    {
        HyperLogLog hll = state.getHyperLogLog();
        if (hll == null) {
            hll = HyperLogLog.newInstance(NUMBER_OF_BUCKETS);
            state.setHyperLogLog(hll);
            state.addMemoryUsage(hll.estimatedInMemorySize());
        }
        return hll;
    }
View Full Code Here

Examples of io.airlift.stats.cardinality.HyperLogLog

    }

    @CombineFunction
    public static void combineState(HyperLogLogState state, HyperLogLogState otherState)
    {
        HyperLogLog input = otherState.getHyperLogLog();

        HyperLogLog previous = state.getHyperLogLog();
        if (previous == null) {
            state.setHyperLogLog(input);
            state.addMemoryUsage(input.estimatedInMemorySize());
        }
        else {
            state.addMemoryUsage(-previous.estimatedInMemorySize());
            previous.mergeWith(input);
            state.addMemoryUsage(previous.estimatedInMemorySize());
        }
    }
View Full Code Here

Examples of io.airlift.stats.cardinality.HyperLogLog

    private ApproximateSetAggregation() {}

    @InputFunction
    public static void input(HyperLogLogState state, @SqlType(StandardTypes.DOUBLE) double value)
    {
        HyperLogLog hll = getOrCreateHyperLogLog(state);
        state.addMemoryUsage(-hll.estimatedInMemorySize());
        hll.add(Double.doubleToLongBits(value));
        state.addMemoryUsage(hll.estimatedInMemorySize());
    }
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.