title: First Mapper produces output from another block (file) and the 1st part files generated holds data from block 2
body: <p>First Mapper produces output from another block (file) and the 1st part files generated holds data from block 2.</p>
  
  <pre><code>import org.apache.hadoop.fs.Path;
  import org.apache.hadoop.io.IntWritable;
  import org.apache.hadoop.io.Text;
  import org.apache.hadoop.mapreduce.Job;
  import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
  import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;
  
  public class MainMaxTemp {
      public static void main(String[] args) throws Exception {
          if (args.length != 2) {
              System.err.println("Usage: MaxTemperature &lt;input path&gt; &lt;output path&gt;");
              System.exit(-1);
          }
          Job job = new Job();
          job.setNumReduceTasks(2);
          job.setJarByClass(MainMaxTemp.class);
          job.setJobName("Max temperature");
          FileInputFormat.addInputPath(job, new Path(args[0]));
          FileOutputFormat.setOutputPath(job, new Path(args[1]));
          job.setMapperClass(WeatherData.class);
          // job.setReducerClass(MaxTemperatureReducer.class);
          job.setOutputKeyClass(Text.class);
          job.setOutputValueClass(IntWritable.class);
          System.exit(job.waitForCompletion(true) ? 0 : 1);
      }
  }
  
  
  import java.io.IOException;
  
  import org.apache.hadoop.io.IntWritable;
  import org.apache.hadoop.io.LongWritable;
  import org.apache.hadoop.io.Text;
  import org.apache.hadoop.mapreduce.Mapper;
  
  public class WeatherData extends Mapper&lt;LongWritable, Text, Text, IntWritable&gt; {
      private static final int MISSING = 9999;
  
      @Override
      public void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException {
          String line = value.toString();
          String words[]=line.split(" ");
          String year = words[0];
          int airTemperature;
  
          airTemperature=Integer.parseInt(words[1]);
          context.write(new Text(year), new IntWritable(airTemperature));
  
      }
  }
  </code></pre>
  
  <p>Input file 1 
  1901 23
  1902 67
  1902 89
  1901 101
  1889 -90
  1700 189
  1901 -9</p>
  
  <p>Input file 2
  2901 23
  2902 67
  2902 89
  2901 101
  2889 -90
  2700 189
  2901 -9</p>
  
  <p>part file 1
  1700    189
  1889    -90
  1902    89
  1902    67
  2901    -9
  2901    101
  2901    23</p>
  
  <p>part file 2
  1901    -9
  1901    101
  1901    23
  2700    189
  2889    -90
  2902    89
  2902    67</p>