Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>The run() method will be called using the Java Run Time Polymorphism (i.e method overriding). As you can see the line# 569 on the link below, extended mapper/reducer will get instantiated using the Java Reflection APIs. The MapTask class gets the name of extended mapper/reducer from the Job configuration object which the client program would have been configured extended mapper/reducer class using <code>job.setMapperClass()</code></p> <p>The following is the code taken from the <a href="http://grepcode.com/file/repository.cloudera.com/content/repositories/releases/com.cloudera.hadoop/hadoop-core/0.20.2-320/org/apache/hadoop/mapred/MapTask.java#MapTask.runNewMapper%28org.apache.hadoop.mapred.JobConf,org.apache.hadoop.io.BytesWritable,org.apache.hadoop.mapred.TaskUmbilicalProtocol,org.apache.hadoop.mapred.Task.TaskReporter%29" rel="nofollow">Hadoop Source MapTask.java</a></p> <pre><code>mapperContext = contextConstructor.newInstance(mapper, job, getTaskID(), input, output, committer, reporter, split); input.initialize(split, mapperContext); mapper.run(mapperContext); input.close();` </code></pre> <p>The line# 621 is an example of run time polymorphism. On this line, the MapTask calls the run() method of configured mapper with 'Mapper Context' as parameter. If the run() is not extended, it calls the run() method on the <code>org.apache.hadoop.mapreduce.Mapper</code> which again calls the map() method on configured mapper.</p> <p>On the line# 616 of the above link, MapTask creates the context object with all the details of job configuration, etc. as mentioned by @harpun and then passes onto the run() method on line # 621. </p> <p>The above explanation holds good for reduce task as well with appropriate ReduceTask class being the main entry class.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload