Package de.jungblut.sketching
Class CountMinSketch<T>
- java.lang.Object
-
- de.jungblut.sketching.CountMinSketch<T>
-
public class CountMinSketch<T> extends java.lang.Object
-
-
Constructor Summary
Constructors Constructor Description CountMinSketch(int tableWidth, int tableHeight, com.google.common.hash.Funnel<T> funnel)Creates a new CountMinSketch.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd(T obj)Adds this object to the min sketch.intapproximateCount(T obj)Gives an approximate count of how often this element was seen throughadd(Object).
-
-
-
Constructor Detail
-
CountMinSketch
public CountMinSketch(int tableWidth, int tableHeight, com.google.common.hash.Funnel<T> funnel)Creates a new CountMinSketch. This will allocate a 2D array of (tableHeight * tableWidth) integers, which is the whole memory constraint of the counting sketch. The height of the table tells how many hash functions to use.- Parameters:
tableWidth- the width of the counter table.tableHeight- the height of the counter table (as in how many hashing functions to use).funnel- the funnel to hash an object.
-
-
Method Detail
-
add
public void add(T obj)
Adds this object to the min sketch.
-
approximateCount
public int approximateCount(T obj)
Gives an approximate count of how often this element was seen throughadd(Object).- Returns:
- 0 if it was never seen, an approximate count otherwise.
-
-