obar1
6/10/2015 - 3:35 PM

wcReducer

import java.io.IOException;

import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Reducer;


public class wcReducer extends Reducer<Text, IntWritable, Text, IntWritable> {

	public void reduce(Text _key, Iterable<IntWritable> values, Context context)
			throws IOException, InterruptedException {
		int sum =0;
		// process values
		for (IntWritable val : values) {
sum += val.get(); // get the int out of InWritable
		}
		context.write(_key, new IntWritable(sum));
	}

}