I
- input typeR
- result typepublic abstract class Aggregator<I,R> extends Object implements 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.
Constructor and Description |
---|
Aggregator() |
Modifier and Type | Method and Description |
---|---|
abstract void |
accumulate(I input)
Accumulates the given entries.
|
abstract R |
aggregate()
Returns the result of the aggregation.
|
abstract void |
combine(Aggregator aggregator)
Incorporates the intermediary result of the given aggregator to this instance of the aggregator.
|
void |
onAccumulationFinished()
Called after the last call to combine on a specific instance.
|
void |
onCombinationFinished()
Called after the last call to combine on a specific instance.
|
public abstract void accumulate(I input)
input
- input to accumulate.public 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.
public abstract 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.public 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.
public abstract R aggregate()
Copyright © 2018 Hazelcast, Inc.. All Rights Reserved.