Search in sources :

Example 1 with Long2DoubleMap

use of it.unimi.dsi.fastutil.longs.Long2DoubleMap in project presto by prestodb.

the class KHyperLogLog method uniquenessDistribution.

public Long2DoubleMap uniquenessDistribution(long histogramSize) {
    Long2DoubleMap out = new Long2DoubleOpenHashMap();
    PrimitiveIterator.OfLong iterator = LongStream.rangeClosed(1, histogramSize).iterator();
    while (iterator.hasNext()) {
        // Initialize all entries to zero
        out.put(iterator.nextLong(), 0D);
    }
    int size = minhash.size();
    for (HyperLogLog hll : minhash.values()) {
        long bucket = Math.min(hll.cardinality(), histogramSize);
        out.merge(bucket, (double) 1 / size, Double::sum);
    }
    return out;
}
Also used : PrimitiveIterator(java.util.PrimitiveIterator) Long2DoubleMap(it.unimi.dsi.fastutil.longs.Long2DoubleMap) Long2DoubleOpenHashMap(it.unimi.dsi.fastutil.longs.Long2DoubleOpenHashMap) HyperLogLog(com.facebook.airlift.stats.cardinality.HyperLogLog)

Aggregations

HyperLogLog (com.facebook.airlift.stats.cardinality.HyperLogLog)1 Long2DoubleMap (it.unimi.dsi.fastutil.longs.Long2DoubleMap)1 Long2DoubleOpenHashMap (it.unimi.dsi.fastutil.longs.Long2DoubleOpenHashMap)1 PrimitiveIterator (java.util.PrimitiveIterator)1