Class HyperLogLogPlusPlus
java.lang.Object
org.elasticsearch.search.aggregations.metrics.HyperLogLogPlusPlus
- All Implemented Interfaces:
java.io.Closeable,java.lang.AutoCloseable,Releasable
public final class HyperLogLogPlusPlus extends java.lang.Object implements Releasable
Hyperloglog++ counter, implemented based on pseudo code from
http://static.googleusercontent.com/media/research.google.com/fr//pubs/archive/40671.pdf and its appendix
https://docs.google.com/document/d/1gyjfMHy43U9OWBXxfaeG-3MjGzejW1dlpyMwEYAAWEI/view?fullscreen
This implementation is different from the original implementation in that it uses a hash table instead of a sorted list for linear
counting. Although this requires more space and makes hyperloglog (which is less accurate) used sooner, this is also considerably faster.
Trying to understand what this class does without having read the paper is considered adventurous.
-
Field Summary
Fields Modifier and Type Field Description static intDEFAULT_PRECISIONstatic intMAX_PRECISIONstatic intMIN_PRECISION -
Constructor Summary
Constructors Constructor Description HyperLogLogPlusPlus(int precision, BigArrays bigArrays, long initialBucketCount) -
Method Summary
Modifier and Type Method Description longcardinality(long bucket)voidclose()voidcollect(long bucket, long hash)booleanequals(long bucket, HyperLogLogPlusPlus other)inthashCode(long bucket)longmaxBucket()static longmemoryUsage(int precision)Return the expected per-bucket memory usage for the given precision.voidmerge(long thisBucket, HyperLogLogPlusPlus other, long otherBucket)intprecision()static intprecisionFromThreshold(long count)Compute the required precision so thatcountdistinct entries would be counted with linear counting.static HyperLogLogPlusPlusreadFrom(StreamInput in, BigArrays bigArrays)voidwriteTo(long bucket, StreamOutput out)
-
Field Details
-
MIN_PRECISION
public static final int MIN_PRECISION- See Also:
- Constant Field Values
-
DEFAULT_PRECISION
public static final int DEFAULT_PRECISION- See Also:
- Constant Field Values
-
MAX_PRECISION
public static final int MAX_PRECISION- See Also:
- Constant Field Values
-
-
Constructor Details
-
Method Details
-
precisionFromThreshold
public static int precisionFromThreshold(long count)Compute the required precision so thatcountdistinct entries would be counted with linear counting. -
memoryUsage
public static long memoryUsage(int precision)Return the expected per-bucket memory usage for the given precision. -
precision
public int precision() -
maxBucket
public long maxBucket() -
merge
-
collect
public void collect(long bucket, long hash) -
cardinality
public long cardinality(long bucket) -
close
public void close()- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable- Specified by:
closein interfaceReleasable
-
hashCode
public int hashCode(long bucket) -
equals
-
writeTo
- Throws:
java.io.IOException
-
readFrom
public static HyperLogLogPlusPlus readFrom(StreamInput in, BigArrays bigArrays) throws java.io.IOException- Throws:
java.io.IOException
-