package WordCount; import org.apache.hadoop.io.IntWritable; import org.apache.hadoop.io.Text; import org.apache.hadoop.mapreduce.Reducer; import java.io.IOException; public class WordCountReducer extends Reducer { /** * 一个单词 一组 执行一次 * b * d 两组 * 执行两次 * 单词 b <1,1,1,1,1,1,1,1,1> * @param key * @param values * @param context * @throws IOException * @throws InterruptedException */ @Override protected void reduce(Text key, Iterable values, Context context) throws IOException, InterruptedException { int number = 0 ; for (IntWritable value : values) { // number++ ; } context.write(key ,new IntWritable(number)); } }