Class CountMinSketch
java.lang.Object
cn.net.pap.common.datastructure.frequency.CountMinSketch
- All Implemented Interfaces:
Serializable
Count-Min Sketch datastructure.
An Improved Data Stream Summary: The Count-Min Sketch and its Applications
https://web.archive.org/web/20060907232042/http://www.eecs.harvard.edu/~michaelm/CS222/countmin.pdf
- See Also:
-
Nested Class Summary
Nested Classes -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionCountMinSketch(double epsOfTotalCount, double confidence, int seed) CountMinSketch(int depth, int width, int seed) -
Method Summary
Modifier and TypeMethodDescriptionvoidadd(long item, long count) voidstatic CountMinSketchdeserialize(byte[] data) booleanlongestimateCount(long item) The estimate is correct within 'epsilon' * (total item count), with probability 'confidence'.longestimateCount(String item) doublestatic int[]getHashBuckets(String key, int hashCount, int max) doubleinthashCode()static CountMinSketchmerge(CountMinSketch... estimators) Merges count min sketches to produce a count min sketch for their combined streamsstatic byte[]serialize(CountMinSketch sketch) longsize()toString()
-
Field Details
-
PRIME_MODULUS
public static final long PRIME_MODULUS- See Also:
-
-
Constructor Details
-
CountMinSketch
public CountMinSketch(int depth, int width, int seed) -
CountMinSketch
public CountMinSketch(double epsOfTotalCount, double confidence, int seed)
-
-
Method Details
-
toString
-
equals
-
hashCode
public int hashCode() -
getRelativeError
public double getRelativeError() -
getConfidence
public double getConfidence() -
add
public void add(long item, long count) -
add
-
size
public long size() -
estimateCount
public long estimateCount(long item) The estimate is correct within 'epsilon' * (total item count), with probability 'confidence'. -
estimateCount
-
merge
public static CountMinSketch merge(CountMinSketch... estimators) throws CountMinSketch.CMSMergeException Merges count min sketches to produce a count min sketch for their combined streams- Parameters:
estimators-- Returns:
- merged estimator or null if no estimators were provided
- Throws:
CountMinSketch.CMSMergeException- if estimators are not mergeable (same depth, width and seed)
-
serialize
-
deserialize
-
getHashBuckets
-