I
- input typeR
- result typepublic interface Aggregator<I,R> extends Serializable
Aggregator does not have to be thread-safe. accumulate() and combine() calls may be interwoven.
The very instance passed to an aggregate() method will not be used at all. It is just a prototype object that will be cloned using serialization, since each partition gets its own instance of an aggregator. In this way the aggregator is not used by multiple-threads. Each thread gets its own aggregator instance.
Modifier and Type | Method and Description |
---|---|
void |
accumulate(I input)
Accumulates the given entries.
|
R |
aggregate()
Returns the result of the aggregation.
|
void |
combine(Aggregator aggregator)
Incorporates the intermediary result of the given aggregator to this instance of the aggregator.
|
default void |
onAccumulationFinished()
Called after the last call to combine on a specific instance.
|
default void |
onCombinationFinished()
Called after the last call to combine on a specific instance.
|
void accumulate(I input)
input
- input to accumulate.default void onAccumulationFinished()
IMPORTANT: It may not be called if the instance aggregator does not take part in the accumulation phase. It's caused by the fact that the aggregation may be run in a parallel way and each thread gets a clone of the aggregator.
void combine(Aggregator aggregator)
aggregator
- aggregator providing intermediary results to be combined into the results of this aggregator.
The given aggregator has to be of the same class as the one that the method is being called on.default void onCombinationFinished()
IMPORTANT: It may not be called if the instance aggregator does not take part in the combination phase. It's caused by the fact that the aggregation may be run in a parallel way and each thread gets a clone of the aggregator.
R aggregate()
Copyright © 2024 Hazelcast, Inc.. All rights reserved.