Guest User

Untitled

a guest
Dec 10th, 2018
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. package info.moaikids.mapred.reduce;
  2.  
  3. import java.io.IOException;
  4.  
  5. import org.apache.hadoop.io.IntWritable;
  6. import org.apache.hadoop.io.Text;
  7. import org.apache.hadoop.mapreduce.Reducer;
  8.  
  9. public class Figure38Reducer extends
  10. Reducer<Text, IntWritable, Text, IntWritable> {
  11.  
  12. static final int MIN = 1;
  13. @Override
  14. protected void reduce(Text key, Iterable<IntWritable> values,
  15. Context context) throws IOException, InterruptedException {
  16. int sum = 0;
  17. for (IntWritable value : values) {
  18. sum += value.get();
  19. }
  20.  
  21. if (sum > MIN) {
  22. context.write(key, new IntWritable(sum));
  23. }
  24. }
  25. }
Add Comment
Please, Sign In to add comment