您的位置:首页 > 其它

按字段分组的Reducer

2016-03-06 00:28 267 查看
<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>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: