标签:
<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>标签:
原文地址:http://blog.csdn.net/u012965373/article/details/50811606