码迷,mamicode.com
首页 > 其他好文 > 详细

按字段分组的Reducer

时间:2016-03-06 10:05:31      阅读:123      评论: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
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!