Advertisement
Guest User

Untitled

a guest
May 29th, 2015
236
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1. import java.io.IOException;
  2. import org.apache.hadoop.io.IntWritable;
  3. import org.apache.hadoop.io.Text;
  4. import org.apache.hadoop.mapreduce.Reducer;
  5.  
  6. public class WordCountReducer extends Reducer<Text, IntWritable, Text, IntWritable> {
  7.  
  8. @Override
  9. public void reduce(Text key, Iterable<IntWritable> values, Context context) throws IOException, InterruptedException {
  10.  
  11. int wordCount = 0;
  12.  
  13. for (IntWritable value : values) {
  14. wordCount = wordCount + value.get();
  15. }
  16.  
  17. context.write(key, new IntWritable(wordCount));
  18. }
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement