public class UniformTimeReservoir extends Object implements TimeReservoir<Long>
long
s. Uses Vitter's Algorithm R to produce a statistically representative
sample.Constructor and Description |
---|
UniformTimeReservoir(int size,
long startTime,
TimeUnit startTimeUnit)
Creates a new
UniformTimeReservoir instance. |
UniformTimeReservoir(long startTime,
TimeUnit startTimeUnit)
Creates a new
UniformTimeReservoir instance of 1024 elements, which offers a 99.9% confidence level
with a 5% margin of error assuming a normal distribution. |
Modifier and Type | Method and Description |
---|---|
UniformTimeSnapshot |
getSnapshot(long time,
TimeUnit timeUnit)
Returns a snapshot of the reservoir's values at given time or newer.
|
long |
interval(TimeUnit timeUnit)
The time interval this reservoir stores data of.
|
int |
size(long time,
TimeUnit timeUnit)
Returns the number of values recorded at given time or newer.
|
void |
update(Long value,
long time,
TimeUnit timeUnit)
Adds a new recorded value to the reservoir bound to a given time.
|
public UniformTimeReservoir(long startTime, TimeUnit startTimeUnit)
UniformTimeReservoir
instance of 1024 elements, which offers a 99.9% confidence level
with a 5% margin of error assuming a normal distribution.startTime
- The start timestartTimeUnit
- The start time unitpublic UniformTimeReservoir(int size, long startTime, TimeUnit startTimeUnit)
UniformTimeReservoir
instance.size
- the number of samples to keep in the sampling reservoirstartTime
- The start timestartTimeUnit
- The start time unitpublic int size(long time, TimeUnit timeUnit)
TimeReservoir
size
in interface TimeReservoir<Long>
time
- The time to get the size fortimeUnit
- Time unit of the provided timepublic void update(Long value, long time, TimeUnit timeUnit)
TimeReservoir
update
in interface TimeReservoir<Long>
value
- a new recorded valuetime
- The time the recorded value occurred attimeUnit
- Time unit of the provided timepublic UniformTimeSnapshot getSnapshot(long time, TimeUnit timeUnit)
TimeReservoir
getSnapshot
in interface TimeReservoir<Long>
time
- The time for which to get the snapshottimeUnit
- Time unit of the provided timepublic long interval(TimeUnit timeUnit)
TimeReservoir
interval
in interface TimeReservoir<Long>
timeUnit
- The time unit in which to get the intervalCopyright © 2007-2024, Oracle and/or its affiliates. All Rights Reserved. Use is subject to license terms.