首页 > 其他 > 详细

按字段分组的Reducer

时间:2016-03-06 10:02:40      阅读:272      评论:0      收藏:0      [点我收藏+]
<strong><span style="font-size:18px;">/***
 * @author YangXin
 * @info 按字段分组的Reducer
 */
package unitTwelve;

import java.io.IOException;

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

public class ByKeyReducer extends Reducer<Text, Text, Text, Text> {
	protected void reduce(Text key, Iterable<Text> values, Context context) throws IOException, InterruptedException{
		StringBuilder output = new StringBuilder();
		for(Text value : values){
			output.append(value.toString()).append(" ");
		}
		context.write(key, new Text(output.toString().trim()));
	}
}
</span></strong>

按字段分组的Reducer

原文:http://blog.csdn.net/u012965373/article/details/50811606

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!