Skip to content

Instantly share code, notes, and snippets.

@sajithdilshan
Created November 21, 2017 08:15
Show Gist options
  • Save sajithdilshan/626f5c7751f9ad521f8f8edc00296211 to your computer and use it in GitHub Desktop.
Save sajithdilshan/626f5c7751f9ad521f8f8edc00296211 to your computer and use it in GitHub Desktop.
public static class IntSumReducer extends Reducer<Text, IntWritable, Text, IntWritable> {
private IntWritable result = new IntWritable();
public void reduce(Text key, Iterable<IntWritable> values, Context context) throws IOException, InterruptedException {
int sum = 0;
for (IntWritable val : values) {
sum += val.get();
}
result.set(sum);
context.write(key, result);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment