public class WindowSketchQuantiles extends java.lang.Object implements Quantiles
This deterministic quantile estimator loosely adapts the idea described in chapter 5 of
"Approximate Counts and Quantiles over Sliding Windows" by Arvind Arasu and Gurmeet
Singh Manku. In detail the data structure described there is used in this class. The query
algorithm used here differs from the paper. In a nutshell the data structure works as follows:
The fixed size window (please refer to setWindowSize(int)
to change the default value)
of a stream gets copied L times, which generated L <it>levels</it>. At one level the stream gets
partitioned into equal sized blocks. Each level has a block size of it's own.
At each block runs an instance of CKMSQuantiles
. To query a quantile, the blocks are used to
reassemble the window, choosing disjoint blocks of different level, starting with big blocks and
filling the remaining spaces using smaller sized blocks.
Modifier and Type | Class and Description |
---|---|
class |
WindowSketchQuantiles.Block
This inner class holds the
GKQuantiles for a specific level. |
static class |
WindowSketchQuantiles.Builder |
class |
WindowSketchQuantiles.Quantiles
Just a wrapper class for a summary (i.e.
|
Constructor and Description |
---|
WindowSketchQuantiles(java.util.Collection<java.lang.Double> monitored,
double epsilon) |
Modifier and Type | Method and Description |
---|---|
java.lang.Double |
get(double q) |
java.util.Collection<java.lang.Double> |
monitored()
Get all monitored quantiles
|
void |
observe(double value)
Add a sample
|
static WindowSketchQuantiles.Builder |
quantiles(double... quantiles) |
void |
setWindowSize(int windowSize)
By default the window size is set to 32768.
|
java.lang.String |
toString() |
public WindowSketchQuantiles(java.util.Collection<java.lang.Double> monitored, double epsilon)
epsilon
- double
that represents the error bound.public void observe(double value)
Quantiles
public java.lang.Double get(double q)
public java.util.Collection<java.lang.Double> monitored()
Quantiles
public final void setWindowSize(int windowSize)
windowSize
- int
value that will be ceiled to the next power of two
before reseting the window size to that value.public java.lang.String toString()
toString
in class java.lang.Object
public static WindowSketchQuantiles.Builder quantiles(double... quantiles)