com.hazelcast.mapreduce

## Class Reducer<ValueIn,ValueOut>

- java.lang.Object
- - com.hazelcast.mapreduce.Reducer<ValueIn,ValueOut>

- Type Parameters:
    `ValueIn` - value type of the incoming values
    `ValueOut` - value type of the reduced values

  Deprecated.
  MapReduce is deprecated and will be removed in 4.0. For map aggregations, you can use `Aggregator` on IMap. For general data processing, it is superseded by Hazelcast Jet.

      @Deprecated
      public abstract class Reducer<ValueIn,ValueOut>
      extends Object

  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.

  Reducers are always called in a thread-safe way. However, they may be moved from one thread to another in the internal thread pool. As of version 3.3.3 the internal state is automatically ensured to be visible according to the Java memory model by the framework. The previous requirement for making fields volatile is dropped.

  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;
         }
       }

  Since:
    3.2

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `Reducer()` Deprecated.

  - ### Method Summary

    All Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `beginReduce()` Deprecated. This method is called before the first value is submitted to this Reducer instance.
    `abstract ValueOut` | `finalizeReduce()` Deprecated. finalizeReduce is called as last step for a reducing phase per key.
    `abstract void` | `reduce(ValueIn value)` Deprecated. 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 reduced value needs to be held 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

    - #### Reducer

          public Reducer()

      Deprecated.

  - ### Method Detail

    - #### beginReduce

          public void beginReduce()

      Deprecated.
      This method is called before the first value is submitted to this Reducer instance. It can be used to set up any internal needed state before starting to reduce the actual values.

    - #### reduce

          public abstract void reduce(ValueIn value)

      Deprecated.
      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 reduced value needs to be held internally in a member state of the Reducer.
      Parameters:
        `value` - value to be reduced

    - #### finalizeReduce

          public abstract ValueOut finalizeReduce()

      Deprecated.
      finalizeReduce is called as last step for a reducing phase per key. It retrieves the final reduced result.
      Returns:
        the final reduced result

Copyright © 2020. All rights reserved.