|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.hazelcast.mapreduce.Reducer<ValueIn,ValueOut>
ValueIn
- value type of the incoming valuesValueOut
- value type of the reduced values@Beta public abstract class Reducer<ValueIn,ValueOut>
The abstract Reducer class is used to build reducers for the Job
.
Reducers may be distributed inside of the cluster but there is always only one Reducer
per key.
Due to the fact that there is only one Reducer per key mapped values needs to be
transmitted to one of the cluster nodes. To reduce the traffic costs between the
nodes a Combiner
implementation can be added to the call which runs alongside
the mapper to pre-reduce mapped values into intermediate results.
A simple Reducer implementation could look like that sum-function implementation:
public class SumReducer implements Reducer<Integer, Integer> { private int sum = 0; public void reduce( Integer value ) { sum += value; } public Integer finalizeReduce() { return sum; } }
Constructor Summary | |
---|---|
Reducer()
|
Method Summary | |
---|---|
void |
beginReduce()
This method is called before the first value is submitted to this Reducer instance. |
abstract ValueOut |
finalizeReduce()
finalizeReduce is called as last step for a reducing phase per key and retrieved the final reduced result. |
abstract void |
reduce(ValueIn value)
This method is called to supply values to be reduced into a final reduced result. The reduce method might be called multiple times so the eventually reduces value needs to be hold internally in a member state of the Reducer. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Reducer()
Method Detail |
---|
public void beginReduce()
public abstract void reduce(ValueIn value)
value
- value to be reducedpublic abstract ValueOut finalizeReduce()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |