E - is the type of data to be countedpublic class CountMinSketch<E> extends Object implements Serializable
| Constructor and Description |
|---|
CountMinSketch(double relativeError,
double confidence)
Instantiate the count min sketch based on a given relative error and confidence
|
| Modifier and Type | Method and Description |
|---|---|
void |
clear()
Clears the counts within the sketch.
|
long[] |
getConfidenceInterval(long count)
Calculate the confidence interval of the approximate count
[approximateCount - (totalNoOfItems * relativeError), approximateCount + (totalNoOfItems * relativeError)]
|
long |
insert(E item)
Adds the count of an item to the count min sketch
calculate hash values relevant for each row in the count array
compute indices in the range of [0, width) from those hash values
increment each value in the cell of relevant row and index (e.g.
|
long |
remove(E item)
Removes the count of an item from the count min sketch
calculate hash values relevant for each row in the count array
compute indices in the range of [0, width) from those hash values
decrement each value in the cell of relevant row and index (e.g.
|
public CountMinSketch(double relativeError,
double confidence)
relativeError - is a positive number less than 1 (e.g. 0.01)confidence - is a positive number less than 1 (e.g. 0.01)
which is the probability of answers being within the relative errorpublic long insert(E item)
item - is the item to be insertedpublic long remove(E item)
item - is the item to be insertedpublic long[] getConfidenceInterval(long count)
count - is the approximate countpublic void clear()
Copyright © 2019 WSO2. All rights reserved.