@InterfaceAudience.Private public class MetricSampleQuantiles extends Object
Modifier and Type | Class and Description |
---|---|
private static class |
MetricSampleQuantiles.SampleItem
Describes a measured value passed to the estimator, tracking additional
metadata required by the CKMS algorithm.
|
Modifier and Type | Field and Description |
---|---|
private long[] |
buffer
Buffers incoming items to be inserted in batch.
|
private int |
bufferCount |
private long |
count
Total number of items in stream
|
private MetricQuantile[] |
quantiles
Array of Quantiles that we care about, along with desired error.
|
private LinkedList<MetricSampleQuantiles.SampleItem> |
samples
Current list of sampled items, maintained in sorted order with error bounds
|
Constructor and Description |
---|
MetricSampleQuantiles(MetricQuantile[] quantiles) |
Modifier and Type | Method and Description |
---|---|
private double |
allowableError(int rank)
Specifies the allowable error for this rank, depending on which quantiles
are being targeted.
|
void |
clear()
Resets the estimator, clearing out all previously inserted items
|
private void |
compress()
Try to remove extraneous items from the set of sampled items.
|
long |
getCount()
Returns the number of items that the estimator has processed
|
int |
getSampleCount()
Returns the number of samples kept by the estimator
|
void |
insert(long v)
Add a new value from the stream.
|
private void |
insertBatch()
Merges items from buffer into the samples array in one pass.
|
private long |
query(double quantile)
Get the estimated value at the specified quantile.
|
Map<MetricQuantile,Long> |
snapshot()
Get a snapshot of the current values of all the tracked quantiles.
|
private long count
private LinkedList<MetricSampleQuantiles.SampleItem> samples
private long[] buffer
private int bufferCount
private final MetricQuantile[] quantiles
public MetricSampleQuantiles(MetricQuantile[] quantiles)
private double allowableError(int rank)
rank
- the index in the list of samplespublic void insert(long v)
v
- the value to insertprivate void insertBatch()
private void compress()
private long query(double quantile) throws IOException
quantile
- Queried quantile, e.g. 0.50 or 0.99.IOException
public Map<MetricQuantile,Long> snapshot() throws IOException
IOException
- if no items have been added to the estimatorpublic long getCount()
public int getSampleCount()
public void clear()
Copyright © 2007–2019 The Apache Software Foundation. All rights reserved.