开发者学堂课程【Hadoop 分布式计算框架 MapReduce:WordCount 案例 Reducer】学习笔记,与课程紧密联系,让用户快速学习知识。
课程地址:https://developer.aliyun.com/learning/course/94/detail/1483
WordCount 案例 Reducer
编写 Reducer 类
package com.atguigu.mapreduce.wordcount ;
import java.io.IOException;
import org.apache.hadoop.io.Intwritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Reducer;
Public class wordcountReducer extenas
Intwritable, Text, Intwritable>{
int aum;
IntWritable v = new Intwritable ( );
@override
protected void reduce (Text key,Iterablevalues ,Contextcontext)
Throws IOException,
InterruptedException {
/ /1累加求和,
sum = 0;
for (Intwritable count : values) {
sum +=count.get ();
}
//2输出