Package org.apache.hadoop.metrics2.util
Class SampleQuantiles
java.lang.Object
org.apache.hadoop.metrics2.util.SampleQuantiles
- All Implemented Interfaces:
QuantileEstimator
Implementation of the Cormode, Korn, Muthukrishnan, and Srivastava algorithm
for streaming calculation of targeted high-percentile epsilon-approximate
quantiles.
This is a generalization of the earlier work by Greenwald and Khanna (GK),
which essentially allows different error bounds on the targeted quantiles,
which allows for far more efficient calculation of high-percentiles.
See: Cormode, Korn, Muthukrishnan, and Srivastava
"Effective Computation of Biased Quantiles over Data Streams" in ICDE 2005
Greenwald and Khanna,
"Space-efficient online computation of quantile summaries" in SIGMOD 2001
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()Resets the estimator, clearing out all previously inserted itemslonggetCount()Returns the number of items that the estimator has processedintReturns the number of samples kept by the estimatorvoidinsert(long v) Add a new value from the stream.snapshot()Get a snapshot of the current values of all the tracked quantiles.toString()
-
Constructor Details
-
SampleQuantiles
-
-
Method Details
-
insert
public void insert(long v) Add a new value from the stream.- Specified by:
insertin interfaceQuantileEstimator- Parameters:
v- v.
-
snapshot
Get a snapshot of the current values of all the tracked quantiles.- Specified by:
snapshotin interfaceQuantileEstimator- Returns:
- snapshot of the tracked quantiles. If no items are added to the estimator, returns null.
-
getCount
public long getCount()Returns the number of items that the estimator has processed- Specified by:
getCountin interfaceQuantileEstimator- Returns:
- count total number of items processed
-
getSampleCount
@VisibleForTesting public int getSampleCount()Returns the number of samples kept by the estimator- Returns:
- count current number of samples
-
clear
public void clear()Resets the estimator, clearing out all previously inserted items- Specified by:
clearin interfaceQuantileEstimator
-
toString
-