title: What exactly is output of mapper and reducer function
body: <p>This is a follow up question of   <a href="https://stackoverflow.com/q/37004413/6119874">Extracting rows containing specific value using mapReduce and hadoop</a><br>
  <strong>Mapper function</strong>  </p>
  
  <pre><code>public static class MapForWordCount extends Mapper&lt;Object, Text, Text, IntWritable&gt;{
  
  private IntWritable saleValue = new IntWritable();
  private Text rangeValue = new Text();
  
  public void map(Object key, Text value, Context con) throws IOException, InterruptedException
  {
      String line = value.toString();
      String[] words = line.split(",");
      for(String word: words )
      {
          if(words[3].equals("40")){  
              saleValue.set(Integer.parseInt(words[0]));
              rangeValue.set(words[3]);
              con.write( rangeValue , saleValue );
          }
      }
  }   
  }
  </code></pre>
  
  <p><strong>Reducer function</strong>  </p>
  
  <pre><code>public static class ReduceForWordCount extends Reducer&lt;Text, IntWritable, Text, IntWritable&gt;  
  {  
      private IntWritable result = new IntWritable();  
      public void reduce(Text word, Iterable&lt;IntWritable&gt; values, Context con) throws IOException, InterruptedException  
      {  
          for(IntWritable value : values)  
          {  
              result.set(value.get());  
              con.write(word, result);  
          }  
      }  
  }
  </code></pre>
  
  <p><strong>Output obtained is</strong>  </p>
  
  <pre><code>40 105  
  40 105  
  40 105  
  40 105
  </code></pre>
  
  <p><strong>EDIT 1 :</strong>
  But the Expected output is</p>
  
  <pre><code>40 102  
  40 104  
  40 105
  </code></pre>
  
  <p><strong>What am I doing wrong ?</strong></p>
  
  <p>What exactly is happening here in mapper and reducer function ?</p>