```java
package com.gosuncn;
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<Text, IntWritable, Text, IntWritable> {
@Override
protected void reduce(Text key, Iterable<IntWritable> values, Context context) throws IOException, InterruptedException {
/**
* 计算key的数量
*/
int count = 0;
for (IntWritable value : values) {
count++;
}
/**
* 将KV写出
*/
context.write(new Text(key), new IntWritable(count));
}
}
```