阅读背景:

按字段分组的Reducer

来源:互联网 

<strong><span>/***
 * @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><strong><span>/***
 * @author YangXin
 * @info 按字段




你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: