title: hadoop get max value in reducer
body: <p>I'm new in hadoop. I have the data: NAICS, Area and Wage from: <a href="https://data.ny.gov/Economic-Development/Quarterly-Census-of-Employment-and-Wages-Annual-Da/shc7-xcbw" rel="nofollow">https://data.ny.gov/Economic-Development/Quarterly-Census-of-Employment-and-Wages-Annual-Da/shc7-xcbw</a>. </p>
  
  <p>My goal is to find in every NAICS the area, where the sum of Wage is the biggest in the statistic using java hadoop. So far I made the Mapper, which will create the context of such form: &lt;NAICS_Area, Wage&gt;, so key is the NAICS and Area connected with "_" and Reducer:</p>
  
  <pre><code>public static class IntSumReducer extends Reducer&lt;Text,LongWritable,Text,LongWritable&gt; {
  private LongWritable result = new LongWritable();
  //private HashMap&lt;String, Long&gt; naicsMax = new HashMap&lt;String, Long&gt;();
  
  public void reduce(Text key, Iterable&lt;LongWritable&gt; values, Context context ) throws IOException, InterruptedException {
    long sum = 0;
    for (LongWritable val : values) {
      sum += val.get();
    }
    result.set(sum);
    context.write(key, result);
  }
  }
  </code></pre>
  
  <p>which will so far create the result such as &lt;NAICS_Area, sum of Wage for given area&gt; , so I have for every Area in every NAICS total sum of Wage, but now I don't know how to continue in my goal. I need to get maximal sum of Wages for Area in each NAICS and I don't know how. Did I make any mistake in my planning mapper or the context like &lt;NAICS_Area, Wage&gt; is correct?</p>
  
  <p>Thanks a lot for your answers</p>