public class ExponentiallyDecayingSample extends Object implements Sample
longs. Uses Cormode et al's forward-decaying
priority reservoir sampling method to produce a statistically representative sample,
exponentially biased towards newer entries.
See
Cormode et al. Forward Decay: A Practical Time Decay Model for Streaming Systems. ICDE '09: Proceedings of the 2009 IEEE International Conference on Data Engineering (2009)| Constructor and Description |
|---|
ExponentiallyDecayingSample(int reservoirSize,
double alpha)
Creates a new
ExponentiallyDecayingSample. |
ExponentiallyDecayingSample(int reservoirSize,
double alpha,
Clock clock)
Creates a new
ExponentiallyDecayingSample. |
| Modifier and Type | Method and Description |
|---|---|
void |
clear()
Clears all recorded values.
|
Snapshot |
getSnapshot()
Returns a snapshot of the sample's values.
|
int |
size()
Returns the number of values recorded.
|
void |
update(long value)
Adds a new recorded value to the sample.
|
void |
update(long value,
long timestamp)
Adds an old value with a fixed timestamp to the sample.
|
public ExponentiallyDecayingSample(int reservoirSize,
double alpha)
ExponentiallyDecayingSample.reservoirSize - the number of samples to keep in the sampling reservoiralpha - the exponential decay factor; the higher this is, the more biased the
sample will be towards newer valuespublic ExponentiallyDecayingSample(int reservoirSize,
double alpha,
Clock clock)
ExponentiallyDecayingSample.reservoirSize - the number of samples to keep in the sampling reservoiralpha - the exponential decay factor; the higher this is, the more biased the
sample will be towards newer valuespublic void clear()
Samplepublic int size()
Samplepublic void update(long value)
Samplepublic void update(long value,
long timestamp)
value - the value to be addedtimestamp - the epoch timestamp of value in secondspublic Snapshot getSnapshot()
SamplegetSnapshot in interface SampleCopyright © 2000-2015 Apache Software Foundation. All Rights Reserved.