The interface Mapper is used to build mappers for the
Job. Most mappers will only need to
implement this interface and the
#map(Object,Object,Context) method to collect and emit needed
key-value pairs.
For more complex algorithms there is the possibility to implement the
LifecycleMapper interface and
override the
LifecycleMapper#initialize(Context) and
LifecycleMapper#finalized(Context)methods as well.
A simple mapper could look like the following example:
public class MyMapper extends Mapper<Integer, Integer, String, Integer>
{
public void map( Integer key, Integer value, Context<String, Integer> context )
{
context.emit( String.valueOf( key ), value );
}
}
If you want to know more about the implementation of MapReduce algorithms read the