public abstract class CountMinSketch
extends Object
ByteShortIntegerLongStringCountMinSketch is initialized with a random seed, and a pair of parameters:
 eps), and
   delta)
 x has appeared in a data
 stream so far.  With probability delta, the estimate of this frequency is within the
 range true frequency <= estimate <= true frequency + eps * N, where N is the
 total count of items have appeared the data stream so far.
 Under the cover, a CountMinSketch is essentially a two-dimensional long array
 with depth d and width w, where
 d = ceil(2 / eps)w = ceil(-log(1 - confidence) / log(2))CountMinSketch class from stream-lib.| Modifier and Type | Class and Description | 
|---|---|
| static class  | CountMinSketch.Version | 
| Constructor and Description | 
|---|
| CountMinSketch() | 
| Modifier and Type | Method and Description | 
|---|---|
| abstract void | add(Object item)Increments  item's count by one. | 
| abstract void | add(Object item,
   long count)Increments  item's count bycount. | 
| abstract void | addBinary(byte[] item)Increments  item's count by one. | 
| abstract void | addBinary(byte[] item,
         long count)Increments  item's count bycount. | 
| abstract void | addLong(long item)Increments  item's count by one. | 
| abstract void | addLong(long item,
       long count)Increments  item's count bycount. | 
| abstract void | addString(String item)Increments  item's count by one. | 
| abstract void | addString(String item,
         long count)Increments  item's count bycount. | 
| abstract double | confidence()Returns the confidence (or  delta) of thisCountMinSketch. | 
| static CountMinSketch | create(double eps,
      double confidence,
      int seed) | 
| static CountMinSketch | create(int depth,
      int width,
      int seed) | 
| abstract int | depth()Depth of this  CountMinSketch. | 
| abstract long | estimateCount(Object item)Returns the estimated frequency of  item. | 
| abstract CountMinSketch | mergeInPlace(CountMinSketch other)Merges another  CountMinSketchwith this one in place. | 
| static CountMinSketch | readFrom(byte[] bytes)Reads in a  CountMinSketchfrom a byte array. | 
| static CountMinSketch | readFrom(java.io.InputStream in)Reads in a  CountMinSketchfrom an input stream. | 
| abstract double | relativeError()Returns the relative error (or  eps) of thisCountMinSketch. | 
| abstract byte[] | toByteArray()Serializes this  CountMinSketchand returns the serialized form. | 
| abstract long | totalCount()Total count of items added to this  CountMinSketchso far. | 
| abstract int | width()Width of this  CountMinSketch. | 
| abstract void | writeTo(java.io.OutputStream out)Writes out this  CountMinSketchto an output stream in binary format. | 
public abstract double relativeError()
eps) of this CountMinSketch.public abstract double confidence()
delta) of this CountMinSketch.public abstract int depth()
CountMinSketch.public abstract int width()
CountMinSketch.public abstract long totalCount()
CountMinSketch so far.public abstract void add(Object item)
item's count by one.public abstract void add(Object item,
                         long count)
item's count by count.public abstract void addLong(long item)
item's count by one.public abstract void addLong(long item,
                             long count)
item's count by count.public abstract void addString(String item)
item's count by one.public abstract void addString(String item,
                               long count)
item's count by count.public abstract void addBinary(byte[] item)
item's count by one.public abstract void addBinary(byte[] item,
                               long count)
item's count by count.public abstract long estimateCount(Object item)
item.public abstract CountMinSketch mergeInPlace(CountMinSketch other) throws IncompatibleMergeException
CountMinSketch with this one in place.
 Note that only Count-Min sketches with the same depth, width, and random seed
 can be merged.IncompatibleMergeException - if the other CountMinSketch has
            incompatible depth, width, relative-error, confidence, or random seed.public abstract void writeTo(java.io.OutputStream out)
                      throws java.io.IOException
CountMinSketch to an output stream in binary format. It is the caller's
 responsibility to close the stream.java.io.IOExceptionpublic abstract byte[] toByteArray()
                            throws java.io.IOException
CountMinSketch and returns the serialized form.java.io.IOExceptionpublic static CountMinSketch readFrom(java.io.InputStream in) throws java.io.IOException
CountMinSketch from an input stream. It is the caller's responsibility to
 close the stream.java.io.IOExceptionpublic static CountMinSketch readFrom(byte[] bytes) throws java.io.IOException
CountMinSketch from a byte array.java.io.IOExceptionpublic static CountMinSketch create(int depth, int width, int seed)
depth - depth of the Count-min Sketch, must be positivewidth - width of the Count-min Sketch, must be positiveseed - random seedpublic static CountMinSketch create(double eps, double confidence, int seed)
eps - relative error, must be positiveconfidence - confidence, must be positive and less than 1.0seed - random seed