T - Type of object stored.public abstract class AbstractNoStoreAggregator<T> extends AbstractTimedAggregator<T>
AbstractTimedAggregator.add(Object) and stores the result after each addition. It processes
the data by using a BinaryFunction which takes the result of the
previous AbstractTimedAggregator.add(Object) and the data passed in and returns a new result
which gets stored (for using again in the next call to AbstractTimedAggregator.add(Object).
The call to AbstractTimedAggregator.evaluate() simply returns this stored value at any
point. This has a lower memory footprint compared to
AbstractListBackedAggregator however it only allows for simpler
processing on the data received.NO_TIMER, TIMER_NAME| Constructor and Description |
|---|
AbstractNoStoreAggregator(BinaryFunction<T,T,T> aggregationFunction)
|
AbstractNoStoreAggregator(BinaryFunction<T,T,T> aggregationFunction,
long interval)
|
AbstractNoStoreAggregator(BinaryFunction<T,T,T> aggregationFunction,
long interval,
boolean useSharedTimer)
Constructs an aggregator which will use the given function, reset itself
at the given interval and will use a shared timer on own private timer.
|
| Modifier and Type | Method and Description |
|---|---|
protected void |
doAdd(T data)
Receives data to be aggregated/processed on the fly.
|
protected T |
doEvaluate()
Returns the value already computed and stored in
result. |
protected void |
doReset()
Resets the
result member to the initialValue(). |
protected abstract T |
initialValue()
Allows subclasses to define the "initial" value.
|
protected int |
retrieveDataSize()
This aggregator doesn't store any data, so the data series size is always
0 (zero).
|
String |
toString() |
add, addTimerListener, evaluate, finalize, getDataSize, getInterval, isSharedTimer, isTimerEnabled, removeTimerListener, reset, stoppublic AbstractNoStoreAggregator(BinaryFunction<T,T,T> aggregationFunction)
aggregationFunction - Aggregation function to use in AbstractTimedAggregator.add(Object). Throws
NullPointerException if this is nullAbstractTimedAggregator.add(Object),
aggregationFunctionpublic AbstractNoStoreAggregator(BinaryFunction<T,T,T> aggregationFunction, long interval)
aggregationFunction - Aggregation function to use in AbstractTimedAggregator.add(Object). Throws
NullPointerException if this is nullinterval - interval in miliseconds to reset this aggregatorAbstractTimedAggregator.add(Object),
aggregationFunctionpublic AbstractNoStoreAggregator(BinaryFunction<T,T,T> aggregationFunction, long interval, boolean useSharedTimer)
AbstractTimedAggregator.add(Object) is called. Also it initializes
result with the value returned by initialValue(), thus
allowing subclasses to have a custom way of specifying the start value.aggregationFunction - Aggregation function to use in AbstractTimedAggregator.add(Object). Throws
NullPointerException if this is nullinterval - interval in miliseconds to reset this aggregatoruseSharedTimer - if set to true, it will use a shared timer, as per
AbstractTimedAggregator.AbstractTimedAggregator(long, boolean)
; otherwise if it's false it will use its own timer instanceAbstractTimedAggregator.AbstractTimedAggregator(long, boolean)protected final void doAdd(T data)
aggregationFunction and stores the result.doAdd in class AbstractTimedAggregator<T>data - Data to aggregateAbstractTimedAggregator.add(Object)protected final T doEvaluate()
result.doEvaluate in class AbstractTimedAggregator<T>resultNullaryFunction.evaluate()protected final void doReset()
result member to the initialValue().doReset in class AbstractTimedAggregator<T>initialValue()protected abstract T initialValue()
result when an instance of this class is created or
when AbstractTimedAggregator.reset() is called.result.protected int retrieveDataSize()
retrieveDataSize in class AbstractTimedAggregator<T>public String toString()
toString in class AbstractTimedAggregator<T>Copyright © 2003–2014 The Apache Software Foundation. All rights reserved.