Package org.xbib.metrics.common
Class ExponentiallyDecayingReservoir
- java.lang.Object
-
- org.xbib.metrics.common.ExponentiallyDecayingReservoir
-
- All Implemented Interfaces:
org.xbib.metrics.api.Reservoir
public class ExponentiallyDecayingReservoir extends java.lang.Object implements org.xbib.metrics.api.ReservoirAn exponentially-decaying random reservoir oflongs. Uses Cormode et al's forward-decaying priority reservoir sampling method to produce a statistically representative sampling reservoir, exponentially biased towards newer entries.
-
-
Constructor Summary
Constructors Constructor Description ExponentiallyDecayingReservoir()Creates a newExponentiallyDecayingReservoirof 1028 elements, which offers a 99.9% confidence level with a 5% margin of error assuming a normal distribution, and an alpha factor of 0.015, which heavily biases the reservoir to the past 5 minutes of measurements.ExponentiallyDecayingReservoir(int size, double alpha)Creates a newExponentiallyDecayingReservoir.ExponentiallyDecayingReservoir(int size, double alpha, org.xbib.metrics.api.Clock clock)Creates a newExponentiallyDecayingReservoir.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description org.xbib.metrics.api.SnapshotgetSnapshot()intsize()voidupdate(long value)voidupdate(long value, long timestamp)Adds an old value with a fixed timestamp to the reservoir.
-
-
-
Constructor Detail
-
ExponentiallyDecayingReservoir
public ExponentiallyDecayingReservoir()
Creates a newExponentiallyDecayingReservoirof 1028 elements, which offers a 99.9% confidence level with a 5% margin of error assuming a normal distribution, and an alpha factor of 0.015, which heavily biases the reservoir to the past 5 minutes of measurements.
-
ExponentiallyDecayingReservoir
public ExponentiallyDecayingReservoir(int size, double alpha)Creates a newExponentiallyDecayingReservoir.- Parameters:
size- the number of samples to keep in the sampling reservoiralpha- the exponential decay factor; the higher this is, the more biased the reservoir will be towards newer values
-
ExponentiallyDecayingReservoir
public ExponentiallyDecayingReservoir(int size, double alpha, org.xbib.metrics.api.Clock clock)Creates a newExponentiallyDecayingReservoir.- Parameters:
size- the number of samples to keep in the sampling reservoiralpha- the exponential decay factor; the higher this is, the more biased the reservoir will be towards newer valuesclock- the clock used to timestamp samples and track rescaling
-
-
Method Detail
-
size
public int size()
- Specified by:
sizein interfaceorg.xbib.metrics.api.Reservoir
-
update
public void update(long value)
- Specified by:
updatein interfaceorg.xbib.metrics.api.Reservoir
-
update
public void update(long value, long timestamp)Adds an old value with a fixed timestamp to the reservoir.- Parameters:
value- the value to be addedtimestamp- the epoch timestamp ofvaluein seconds
-
getSnapshot
public org.xbib.metrics.api.Snapshot getSnapshot()
- Specified by:
getSnapshotin interfaceorg.xbib.metrics.api.Reservoir
-
-