Package com.codahale.metrics
Class UniformReservoir
- java.lang.Object
-
- com.codahale.metrics.UniformReservoir
-
- All Implemented Interfaces:
Reservoir
public class UniformReservoir extends Object implements Reservoir
A random sampling reservoir of a stream oflongs. Uses Vitter's Algorithm R to produce a statistically representative sample.- See Also:
- Random Sampling with a Reservoir
-
-
Constructor Summary
Constructors Constructor Description UniformReservoir()Creates a newUniformReservoirof 1028 elements, which offers a 99.9% confidence level with a 5% margin of error assuming a normal distribution.UniformReservoir(int size)Creates a newUniformReservoir.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description SnapshotgetSnapshot()Returns a snapshot of the reservoir's values.intsize()Returns the number of values recorded.voidupdate(long value)Adds a new recorded value to the reservoir.
-
-
-
Constructor Detail
-
UniformReservoir
public UniformReservoir()
Creates a newUniformReservoirof 1028 elements, which offers a 99.9% confidence level with a 5% margin of error assuming a normal distribution.
-
UniformReservoir
public UniformReservoir(int size)
Creates a newUniformReservoir.- Parameters:
size- the number of samples to keep in the sampling reservoir
-
-
Method Detail
-
size
public int size()
Description copied from interface:ReservoirReturns the number of values recorded.
-
update
public void update(long value)
Description copied from interface:ReservoirAdds a new recorded value to the reservoir.
-
getSnapshot
public Snapshot getSnapshot()
Description copied from interface:ReservoirReturns a snapshot of the reservoir's values.- Specified by:
getSnapshotin interfaceReservoir- Returns:
- a snapshot of the reservoir's values
-
-