com.hazelcast.mapreduce

## Class LifecycleMapperAdapter<KeyIn,ValueIn,KeyOut,ValueOut>

- java.lang.Object
- - com.hazelcast.mapreduce.LifecycleMapperAdapter<KeyIn,ValueIn,KeyOut,ValueOut>

- Type Parameters:
    `KeyIn` - type of key used in the `KeyValueSource`
    `ValueIn` - type of value used in the `KeyValueSource`
    `KeyOut` - key type for mapped results
    `ValueOut` - value type for mapped results
  All Implemented Interfaces:
    LifecycleMapper<KeyIn,ValueIn,KeyOut,ValueOut>, Mapper<KeyIn,ValueIn,KeyOut,ValueOut>, Serializable

  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 LifecycleMapperAdapter<KeyIn,ValueIn,KeyOut,ValueOut>
      extends Object
      implements LifecycleMapper<KeyIn,ValueIn,KeyOut,ValueOut>

  The abstract LifecycleMapperAdapter superclass is used to ease building mappers for the `Job`. Most mappers will only implement the `map(Object, Object, Context)` method to collect and emit needed key-value pairs.
  For more complex algorithms there is the possibility to override the `initialize(Context)` and `finalized(Context)` methods as well.

  A simple mapper could look like the following example:

       public static class MyMapper extends LifecycleMapperAdapter<Integer, Integer, String, Integer>
       {
         public void map( Integer key, Integer value, Context<String, Integer> collector )
         {
           collector.emit( String.valueOf( key ), value );
         }
       }

  If you want to know more about the implementation of MapReduce algorithms read the Google Whitepaper on MapReduce.

  Since:
    3.2
  See Also:
    Serialized Form

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `LifecycleMapperAdapter()` Deprecated.

  - ### Method Summary

    All Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `finalized(Context<KeyOut,ValueOut> context)` Deprecated. This method is called after the `Mapper.map(Object, Object, Context)` method is executed for every value and can be used to finalize the internal state of the mapper or to emit a special value.
    `void` | `initialize(Context<KeyOut,ValueOut> context)` Deprecated. This method is called before the `Mapper.map(Object, Object, Context)` method is executed for every value and can be used to initialize the internal state of the mapper or to emit a special value.
    `abstract void` | `map(KeyIn key, ValueIn value, Context<KeyOut,ValueOut> context)` Deprecated. The map method is called for every single key-value pair in the bound `KeyValueSource` instance on this cluster node and partition. Due to its nature of a DataGrid, Hazelcast distributes values all over the cluster and so this method is executed on multiple servers at the same time. If you want to know more about the implementation of MapReduce algorithms read the Google Whitepaper on MapReduce.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### LifecycleMapperAdapter

          public LifecycleMapperAdapter()

      Deprecated.

  - ### Method Detail

    - #### initialize

          public void initialize(Context<KeyOut,ValueOut> context)

      Deprecated.
      This method is called before the `Mapper.map(Object, Object, Context)` method is executed for every value and can be used to initialize the internal state of the mapper or to emit a special value.
      Specified by:
        `initialize` in interface `LifecycleMapper<KeyIn,ValueIn,KeyOut,ValueOut>`
      Parameters:
        `context` - Context to be used for emitting values

    - #### map

          public abstract void map(KeyIn key,
                                   ValueIn value,
                                   Context<KeyOut,ValueOut> context)

      Deprecated.
      The map method is called for every single key-value pair in the bound `KeyValueSource` instance on this cluster node and partition.
      Due to its nature of a DataGrid, Hazelcast distributes values all over the cluster and so this method is executed on multiple servers at the same time.
      If you want to know more about the implementation of MapReduce algorithms read the Google Whitepaper on MapReduce.
      Specified by:
        `map` in interface `Mapper<KeyIn,ValueIn,KeyOut,ValueOut>`
      Parameters:
        `key` - key to map
        `value` - value to map
        `context` - Context to be used for emitting values

    - #### finalized

          public void finalized(Context<KeyOut,ValueOut> context)

      Deprecated.
      This method is called after the `Mapper.map(Object, Object, Context)` method is executed for every value and can be used to finalize the internal state of the mapper or to emit a special value.
      Specified by:
        `finalized` in interface `LifecycleMapper<KeyIn,ValueIn,KeyOut,ValueOut>`
      Parameters:
        `context` - Context to be used for emitting values

Copyright © 2018. All rights reserved.