Skip to content

Instantly share code, notes, and snippets.

@rei999
Created July 10, 2013 01:00
Show Gist options
  • Select an option

  • Save rei999/5962685 to your computer and use it in GitHub Desktop.

Select an option

Save rei999/5962685 to your computer and use it in GitHub Desktop.
example hadoop reducer
package com.mycompany.emr;
import java.io.IOException;
import java.util.*;
import org.apache.hadoop.io.*;
import org.apache.hadoop.mapreduce.*;
public class Reduce extends Reducer<Text, IntWritable, Text, IntWritable> {
public void reduce(Text key, Iterable<IntWritable> values, Context context)
throws IOException, InterruptedException {
int sum = 0;
for (IntWritable val : values) {
sum += val.get();
}
context.write(key, new IntWritable(sum));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment