@InterfaceAudience.Private @InterfaceStability.Unstable public abstract class PeriodicStatsAccumulator extends Object
The sole constructor is called with a count, which is the number of buckets into which we evenly divide the spectrum of progress from 0.0D to 1.0D . In the future we may provide for custom split points that don't have to be uniform.
A subclass determines how we fold readings for portions of a
bucket and how we interpret the readings by overriding
extendInternal(...)
and initializeInterval()
Modifier and Type | Field and Description |
---|---|
protected int |
count |
protected int[] |
values |
Modifier and Type | Method and Description |
---|---|
protected void |
advanceState(double newProgress,
int newValue) |
protected void |
extend(double newProgress,
int newValue)
This method calls
extendInternal at least once. |
protected abstract void |
extendInternal(double newProgress,
int newValue)
adds a new reading to the current bucket.
|
protected int[] |
getValues() |
protected void |
initializeInterval()
initializes the state variables to be ready for a new interval
|
protected int[] getValues()
protected abstract void extendInternal(double newProgress, int newValue)
newProgress
- the endpoint of the interval this new
reading coversnewValue
- the value of the reading at newProgress
The class has three instance variables, oldProgress
and
oldValue
and currentAccumulation
.
extendInternal
can count on three things:
1: The first time it's called in a particular instance, both
oldXXX's will be zero.
2: oldXXX for a later call is the value of newXXX of the
previous call. This ensures continuity in accumulation from
one call to the next.
3: currentAccumulation
is owned by
initializeInterval
and extendInternal
.protected void initializeInterval()
protected void extend(double newProgress, int newValue)
extendInternal
at least once. It
divides the current progress interval [from the last call's
newProgress
to this call's newProgress
]
into one or more subintervals by splitting at any point which
is an interval boundary if there are any such points. It
then calls extendInternal
for each subinterval, or the
whole interval if there are no splitting points.
For example, if the value was 300
last time with
0.3
progress, and count is 5
, and you get a
new reading with the variable at 700
and progress at
0.7
, you get three calls to extendInternal
:
one extending from progress 0.3
to 0.4
[the
next boundary] with a value of 400
, the next one
through 0.6
with a value of 600
, and finally
one at 700
with a progress of 0.7
.
newProgress
- the endpoint of the progress range this new
reading coversnewValue
- the value of the reading at newProgress
protected void advanceState(double newProgress, int newValue)
Copyright © 2020 Apache Software Foundation. All rights reserved.