public abstract class KllFloatsSketch extends KllSketch
KllSketch.SketchType| Modifier and Type | Method and Description |
|---|---|
double[] |
getCDF(float[] splitPoints)
Returns an approximation to the Cumulative Distribution Function (CDF), which is the
cumulative analog of the PMF, of the input stream given a set of splitPoint (values).
|
static int |
getMaxSerializedSizeBytes(int k,
long n,
boolean updatableMemoryFormat)
Returns upper bound on the serialized size of a KllFloatsSketch given the following parameters.
|
float |
getMaxValue()
Returns the max value of the stream.
|
float |
getMinValue()
Returns the min value of the stream.
|
double[] |
getPMF(float[] splitPoints)
Returns an approximation to the Probability Mass Function (PMF) of the input stream
given a set of splitPoints (values).
|
float |
getQuantile(double fraction)
Returns an approximation to the value of the data item
that would be preceded by the given fraction of a hypothetical sorted
version of the input stream so far.
|
float |
getQuantileLowerBound(double fraction)
Gets the lower bound of the value interval in which the true quantile of the given rank
exists with a confidence of at least 99%.
|
float[] |
getQuantiles(double[] fractions)
This is a more efficient multiple-query version of getQuantile().
|
float[] |
getQuantiles(int numEvenlySpaced)
This is also a more efficient multiple-query version of getQuantile() and allows the caller to
specify the number of evenly spaced fractional ranks.
|
float |
getQuantileUpperBound(double fraction)
Gets the upper bound of the value interval in which the true quantile of the given rank
exists with a confidence of at least 99%.
|
double |
getRank(float value)
Returns an approximation to the normalized (fractional) rank of the given value from 0 to 1,
inclusive.
|
static KllFloatsSketch |
heapify(org.apache.datasketches.memory.Memory srcMem)
Factory heapify takes the sketch image in Memory and instantiates an on-heap sketch.
|
KllFloatsSketchIterator |
iterator() |
static KllFloatsSketch |
newDirectInstance(int k,
org.apache.datasketches.memory.WritableMemory dstMem,
org.apache.datasketches.memory.MemoryRequestServer memReqSvr)
Create a new direct instance of this sketch with a given k.
|
static KllFloatsSketch |
newDirectInstance(org.apache.datasketches.memory.WritableMemory dstMem,
org.apache.datasketches.memory.MemoryRequestServer memReqSvr)
Create a new direct instance of this sketch with the default k.
|
static KllFloatsSketch |
newHeapInstance()
Create a new heap instance of this sketch with the default k = 200.
|
static KllFloatsSketch |
newHeapInstance(int k)
Create a new heap instance of this sketch with a given parameter k.
|
void |
update(float value)
Updates this sketch with the given data item.
|
static KllFloatsSketch |
wrap(org.apache.datasketches.memory.Memory srcMem)
Wrap a sketch around the given read only source Memory containing sketch data
that originated from this sketch.
|
static KllFloatsSketch |
writableWrap(org.apache.datasketches.memory.WritableMemory srcMem,
org.apache.datasketches.memory.MemoryRequestServer memReqSvr)
Wrap a sketch around the given source Writable Memory containing sketch data
that originated from this sketch.
|
getCurrentCompactSerializedSizeBytes, getCurrentUpdatableSerializedSizeBytes, getK, getKFromEpsilon, getMaxSerializedSizeBytes, getMaxSerializedSizeBytes, getN, getNormalizedRankError, getNormalizedRankError, getNumRetained, getSerializedSizeBytes, hasMemory, isDirect, isEmpty, isEstimationMode, isMemoryUpdatableFormat, isReadOnly, isSameResource, merge, reset, toByteArray, toString, toStringpublic static int getMaxSerializedSizeBytes(int k,
long n,
boolean updatableMemoryFormat)
k - parameter that controls size of the sketch and accuracy of estimatesn - stream lengthupdatableMemoryFormat - true if updatable Memory format, otherwise the standard compact format.public static KllFloatsSketch heapify(org.apache.datasketches.memory.Memory srcMem)
srcMem - a Memory image of a sketch serialized by this sketch.
See Memorypublic static KllFloatsSketch newDirectInstance(int k, org.apache.datasketches.memory.WritableMemory dstMem, org.apache.datasketches.memory.MemoryRequestServer memReqSvr)
k - parameter that controls size of the sketch and accuracy of estimates.dstMem - the given destination WritableMemory object for use by the sketchmemReqSvr - the given MemoryRequestServer to request a larger WritableMemorypublic static KllFloatsSketch newDirectInstance(org.apache.datasketches.memory.WritableMemory dstMem, org.apache.datasketches.memory.MemoryRequestServer memReqSvr)
dstMem - the given destination WritableMemory object for use by the sketchmemReqSvr - the given MemoryRequestServer to request a larger WritableMemorypublic static KllFloatsSketch newHeapInstance()
public static KllFloatsSketch newHeapInstance(int k)
k - parameter that controls size of the sketch and accuracy of estimates.public static KllFloatsSketch wrap(org.apache.datasketches.memory.Memory srcMem)
srcMem - the read only source Memorypublic static KllFloatsSketch writableWrap(org.apache.datasketches.memory.WritableMemory srcMem, org.apache.datasketches.memory.MemoryRequestServer memReqSvr)
srcMem - a WritableMemory that contains data.memReqSvr - the given MemoryRequestServer to request a larger WritableMemorypublic double[] getCDF(float[] splitPoints)
The resulting approximations have a probabilistic guarantee that can be obtained from the getNormalizedRankError(false) function.
If the sketch is empty this returns null.
splitPoints - an array of m unique, monotonically increasing float values
that divide the real number line into m+1 consecutive disjoint intervals.
The definition of an "interval" is inclusive of the left splitPoint (or minimum value) and
exclusive of the right splitPoint, with the exception that the last interval will include
the maximum value.
It is not necessary to include either the min or max values in these split points.public float getMaxValue()
public float getMinValue()
public double[] getPMF(float[] splitPoints)
The resulting approximations have a probabilistic guarantee that can be obtained from the getNormalizedRankError(true) function.
If the sketch is empty this returns null.
splitPoints - an array of m unique, monotonically increasing float values
that divide the real number line into m+1 consecutive disjoint intervals.
The definition of an "interval" is inclusive of the left splitPoint (or minimum value) and
exclusive of the right splitPoint, with the exception that the last interval will include
the maximum value.
It is not necessary to include either the min or max values in these split points.public float getQuantile(double fraction)
We note that this method has a fairly large overhead (microseconds instead of nanoseconds) so it should not be called multiple times to get different quantiles from the same sketch. Instead use getQuantiles(), which pays the overhead only once.
If the sketch is empty this returns NaN.
fraction - the specified fractional position in the hypothetical sorted stream.
These are also called normalized ranks or fractional ranks.
If fraction = 0.0, the true minimum value of the stream is returned.
If fraction = 1.0, the true maximum value of the stream is returned.public float getQuantileLowerBound(double fraction)
fraction - the given normalized rank as a fractionpublic float[] getQuantiles(double[] fractions)
This returns an array that could have been generated by using getQuantile() with many different fractional ranks, but would be very inefficient. This method incurs the internal set-up overhead once and obtains multiple quantile values in a single query. It is strongly recommend that this method be used instead of multiple calls to getQuantile().
If the sketch is empty this returns null.
fractions - given array of fractional positions in the hypothetical sorted stream.
These are also called normalized ranks or fractional ranks.
These fractions must be in the interval [0.0, 1.0], inclusive.public float[] getQuantiles(int numEvenlySpaced)
If the sketch is empty this returns null.
numEvenlySpaced - an integer that specifies the number of evenly spaced fractional ranks.
This must be a positive integer greater than 0. A value of 1 will return the min value.
A value of 2 will return the min and the max value. A value of 3 will return the min,
the median and the max value, etc.public float getQuantileUpperBound(double fraction)
fraction - the given normalized rank as a fractionpublic double getRank(float value)
The resulting approximation has a probabilistic guarantee that can be obtained from the getNormalizedRankError(false) function.
If the sketch is empty this returns NaN.
value - to be rankedpublic KllFloatsSketchIterator iterator()
public void update(float value)
value - an item from a stream of items. NaNs are ignored.Copyright © 2015–2020 The Apache Software Foundation. All rights reserved.