Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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 Figure38Reducer extends
- Reducer<Text, IntWritable, Text, IntWritable> {
- static final int MIN = 1;
- @Override
- protected void reduce(Text key, Iterable<IntWritable> values,
- Context context) throws IOException, InterruptedException {
- int sum = 0;
- for (IntWritable value : values) {
- sum += value.get();
- }
- if (sum > MIN) {
- context.write(key, new IntWritable(sum));
- }
- }
- }
Add Comment
Please, Sign In to add comment