title: Why Context.Write not working as expected- Hadoop Map reduce
body: <p>I have 1 MR job and its output looks like :</p>
  
  <pre><code>128.187.140.171,11
  129.109.6.54,27
  129.188.154.200,44
  129.193.116.41,5
  129.217.186.112,17
  </code></pre>
  
  <p>In the mapper code of 2nd MR job, I am doing this ;</p>
  
  <pre><code>public void map(LongWritable key, Text value, Context context)
              throws IOException, InterruptedException {
          // Parse the input string into a nice map
          // System.out.println(value.toString());
          if (value.toString().contains(",")) {
              System.out.println("Inside");
              String[] arr = value.toString().split(",");
              if (arr.length &gt; 1) {
                  System.out.println(arr[1]);
                  context.write(new Text(arr[1]), new Text(arr[0]));
              }
          }
  </code></pre>
  
  <p>The output of print statements are correct :</p>
  
  <pre><code>Inside
  11
  Inside
  27
  </code></pre>
  
  <p>But the context.write keeps showing following output :</p>
  
  <pre><code>1,slip4068.sirius.com
  1,hstar.gsfc.nasa.gov
  1,ad11-010.compuserve.com
  1,slip85-2.co.us.ibm.net
  1,stimpy.actrix.gen.nz
  1,j14.ktk1.jaring.my
  1,ad08-009.compuserve.com 
  </code></pre>
  
  <p>Why I keep getting 1 in the Keys ?
  This is my driver code:</p>
  
  <pre><code>public int run(String[] args) throws Exception {
          // TODO Auto-generated method stub
          Configuration conf = getConf();
          conf.set("mapreduce.output.textoutputformat.separator", ",");
  
          Job job = new Job(conf, "WL Demo");
  
          job.setJarByClass(WLDemo.class);
  
          job.setMapperClass(WLMapper1.class);
  
      job.setReducerClass(WLReducer1.class);
              job.setInputFormatClass(TextInputFormat.class);
  
      job.setOutputKeyClass(Text.class);
  
      job.setOutputValueClass(IntWritable.class);
  
      Path in = new Path(args[0]);
  
      Path out = new Path(args[1]);
  
      Path out2 = new Path(args[2]);
  
      FileInputFormat.setInputPaths(job, in);
  
      FileOutputFormat.setOutputPath(job, out);
  
      boolean succ = job.waitForCompletion(true);
      if (!succ) {
          System.out.println("Job1 failed, exiting");
          return -1;
      }
      Job job2 = new Job(conf, "top-k-pass-2");
      FileInputFormat.setInputPaths(job2, out);
      FileOutputFormat.setOutputPath(job2, out2);
      job2.setJarByClass(WLDemo.class);
      job2.setMapperClass(WLMapper2.class);
      // job2.setReducerClass(Reducer1.class);
      job2.setInputFormatClass(TextInputFormat.class);
  
      job2.setMapOutputKeyClass(Text.class);
      job2.setMapOutputValueClass(Text.class);
      job2.setNumReduceTasks(1);
      succ = job2.waitForCompletion(true);
      if (!succ) {
          System.out.println("Job2 failed, exiting");
          return -1;
      }
      return 0;
  }
  </code></pre>
  
  <p>How can I get correct values in output key of my 2nd MR job ?</p>