按字段分组的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>
相关文章推荐
- 按字段分组的Mapper
- C++中变量的作用域与生命周期
- 用过coreData或者sqlite吗?读写是分线程的吗?
- GCD中有哪几种Queue?你自己建立过串行Queue吗?背后的线程模型是什么样的
- Maven 的基本用法
- ubuntu建立快捷方式
- ubuntu建立快捷方式
- 20145208 《Java程序设计》第一周学习总结
- Android的IPC机制实现方式之Messenger
- viewWillLayoutSubView
- 冒泡排序
- html的onChange是会误导人的------输入框变化且焦点离开才会触发
- loadView是干什么用的
- sudo
- 使用详解及源码解析Android中的Adapter、BaseAdapter、ArrayAdapter、SimpleAdapter和SimpleCursorAdapter
- setGeometryDp: Unable to set geometry 22x22+672+353 on QWidgetWindow/'QDialogClassWindow'.
- 安卓第六天笔记--ListView
- Linux Swap交换分区介绍总结
- ansible的用法
- 浏览器缓存--阅读笔记