ChainMapper/ChainReducer 的实现原理
来源:互联网 发布:java程序分为哪两类 编辑:程序博客网 时间:2024/04/30 04:19
图1 ChainMapper/ChainReducer 应用实例
图2 一个ChainMapper/ChainReducer 不适用的场景
一个实例:
conf.setJobName("chain");
conf.setInputFormat(TextInputFormat.class);
conf.setOutputFormat(TextOutputFormat.class);
JobConf mapper1Conf = new JobConf(false);
JobConf mapper2Conf = new JobConf(false);
JobConf reduce1Conf = new JobConf(false);
JobConf mapper3Conf = new JobConf(false);
…
ChainMapper.addMapper(conf, Mapper1.class, LongWritable.class, Text.class,Text.
class, Text.class, true, mapper1Conf);
ChainMapper.addMapper(conf, Mapper2.class, Text.class, Text.class,
LongWritable.class, Text.class, false, mapper2Conf);
ChainReducer.setReducer(conf, Reducer.class, LongWritable.class, Text.class,Text.
class, Text.class, true, reduce1Conf);
ChainReducer.addMapper(conf, Mapper3.class, Text.class, Text.class,
LongWritable.class, Text.class, false, null);
JobClient.runJob(conf);
用户通过addMapper 在Map/Reduce 阶段添加多个Mapper。该函数带有8 个输入参数,分别是作业的配置、Mapper 类、Mapper 的输入key 类型、输入value 类型、输出key
类型、输出value 类型、key/value 是否按值传递和Mapper 的配置。其中,第7 个参数需要解释一下:Hadoop MapReduce 有一个约定,函数OutputCollector.collect(key, value) 执行期间不应改变key 和value 的值。这主要是因为函数Mapper.map() 调用完OutputCollector.collect(key, value) 之后,可能会再次使用key 和value 值,如果被改变,可能会造成潜在的错误。为了防止OutputCollector 直接对key/value 修改,ChainMapper 允许用户指定key/value 传递方式。如果用户确定key/value 不会被修改,则可选用按引用传递,否则按值传递。需要注意的是,引用传递可避免对象拷贝,提高处理效率,但需要确保key/value 不会被修改。
原文引自《Hadoop技术内幕-深入解析Mapreduce框架设计与实现原理》
- ChainMapper/ChainReducer 的实现原理
- ChainMapper/ChainReducer的实现原理
- ChainMapper/ChainReducer实现原理
- ChainMapper/ChainReducer实现原理及案例分析
- Hadoop的ChainMapper/ChainReducer
- 如何使用Hadoop的ChainMapper和ChainReducer
- 如何使用Hadoop的ChainMapper和ChainReducer
- 如何使用Hadoop的ChainMapper和ChainReducer
- Hadoop2.X的ChainMapper和ChainReducer
- ChainMapper和ChainReducer
- ChainMapper和ChainReducer
- ChainMapper和ChainReducer
- hadoop 2.0中ChainMapper与ChainReducer的使用
- [Hadoop] Hadoop 链式任务 : ChainMapper and ChainReducer的使用
- MapReduce练习二:ChainMapper和ChainReducer的使用
- 链式MapReduce:ChainMapper和ChainReducer
- MR简单串联(ChainMapper/ChainReducer)
- MapReduce基础开发之十二ChainMapper和ChainReducer使用
- 简明Python3教程 19.附录 FLOSS
- Python算法(含源代码下载)
- 使用Wireshark抓取SNMP Trap包
- 简明Python3教程(A Byte of Python 3)
- C#实现窗口最小化到系统托盘
- ChainMapper/ChainReducer 的实现原理
- C#日期时间格式化
- 使用CMD实现批量重命名[转]
- Python高效编程技巧
- mysql 取得表中重复值之间的间隔以及最大间隔
- 实用WordPress后台MySQL操作命令
- PHP设置时区,记录日志文件的方法
- 微信公众平台消息接口使用指南
- 深圳移动 神州行(大众卡/轻松卡/幸福卡)套餐资费(含香港日套餐)信息及使用方法