title: Multiple mappers in hadoop
body: <p>I am trying to run 2 independent mappers on the same input file in a hadoop program using one job. I want the output of both the mappers to go into a single reducer. I face an issue with running multiple mappers. I was using MultipleInputs class. It was working fine by running both the mappers but yesterday i noticed that it is running only one map function that is the second MultipleInputs statement seems to overwrite the first one. I dont find any change done to the code to show this different behavior suddenly :( Please help me in this.. The main function is :</p>
  
  <pre><code>    public static void main(String[] args) throws Exception {
              Configuration conf = new Configuration();
              Job job = new Job(conf, "mapper accepting whole file at once");          
              job.setOutputKeyClass(IntWritable.class);
              job.setOutputValueClass(IntWritable.class);
              job.setJarByClass(TestMultipleInputs.class);
              job.setMapperClass(Map2.class);    
              job.setMapperClass(Map1.class);  
              job.setReducerClass(Reduce.class);  
              job.setInputFormatClass(NLinesInputFormat.class);
              job.setOutputFormatClass(TextOutputFormat.class);
              job.setMapOutputKeyClass(IntWritable.class);
  **  MultipleInputs.addInputPath(job, new Path("Rec"), NLinesInputFormat.class, Map1.class);
      MultipleInputs.addInputPath(job, new Path("Rec"), NLinesInputFormat.class, Map2.class);**    
              FileOutputFormat.setOutputPath(job,new Path("testMulinput"));
                job.waitForCompletion(true);
  }
  </code></pre>
  
  <p>Whichever Map class is used in the last MultipleInputs statement gets executed. Like in here the Map2.class gets executed.</p>