Skip to content

Instantly share code, notes, and snippets.

Created August 26, 2012 06:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/3475195 to your computer and use it in GitHub Desktop.
Save anonymous/3475195 to your computer and use it in GitHub Desktop.
Data Intensive Text Processing with MapReduce #3 figure3.1 Reducer
package info.moaikids.mapred.reduce;
import java.io.IOException;
import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Reducer;
public class Figure31Reducer extends Reducer<Text, IntWritable, Text, IntWritable> {
@Override
protected void reduce(Text key, Iterable<IntWritable> values, Context context)
throws IOException, InterruptedException {
int sum = 0;
for (IntWritable value : values) {
sum += value.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