Class AbstractLinearCounting
java.lang.Object
org.elasticsearch.search.aggregations.metrics.AbstractLinearCounting
public abstract class AbstractLinearCounting
extends java.lang.Object
Linear 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
Trying to understand what this class does without having read the paper is considered adventurous.
The algorithm just keep a record of all distinct values provided encoded as an integer.
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
AbstractLinearCounting.HashesIterator
Iterator over the hash values -
Field Summary
Fields Modifier and Type Field Description static int
MAX_PRECISION
static int
MIN_PRECISION
protected int
p
-
Constructor Summary
Constructors Constructor Description AbstractLinearCounting(int precision)
-
Method Summary
Modifier and Type Method Description protected abstract int
addEncoded(long bucketOrd, int encoded)
Add encoded value to the linear counting.long
cardinality(long bucketOrd)
Returns the current computed cardinalityint
collect(long bucketOrd, long hash)
int
precision()
Precision of the algorithmprotected abstract int
size(long bucketOrd)
number of values in the counter.protected abstract AbstractLinearCounting.HashesIterator
values(long bucketOrd)
return the current values in the counter.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Field Details
-
MIN_PRECISION
public static final int MIN_PRECISION- See Also:
- Constant Field Values
-
MAX_PRECISION
public static final int MAX_PRECISION- See Also:
- Constant Field Values
-
p
protected final int p
-
-
Constructor Details
-
AbstractLinearCounting
public AbstractLinearCounting(int precision)
-
-
Method Details
-
addEncoded
protected abstract int addEncoded(long bucketOrd, int encoded)Add encoded value to the linear counting. Implementor should only accept the value if it has not been seen before. -
size
protected abstract int size(long bucketOrd)number of values in the counter. -
values
return the current values in the counter. -
collect
public int collect(long bucketOrd, long hash) -
cardinality
public long cardinality(long bucketOrd)Returns the current computed cardinality -
precision
public int precision()Precision of the algorithm
-