024_MapReduce中的基类Mapper和基类Reducer
内容提纲
1) MapReduce中的基类Mapper类,自定义Mapper类的父类。
2) MapReduce中的基类Reducer类,自定义Reducer类的父类。
1、Mapper类
API文档
1) InputSplit输入分片,InputFormat输入格式化
2) 对Mapper输出结果进行Sorted排序和Group分组
3) 对Mapper输出结果依据Reducer个数进行分区Patition
4) 对Mapper输出数据进行Combiner
- 在Hadoop官方文档的Mapper类说明:
Maps input key/value pairs to a set of intermediate key/value pairs.
Maps are the individual tasks which transform input records into a intermediate records. The transformed intermediate records need not be of the same type as the input records. A given input pair may map to zero or many output pairs.
The Hadoop Map-Reduce framework spawns one map task for each InputSplit generated by the InputFormat for the job. Mapper implementations can access the Configuration for the job via the JobContext.getConfiguration().
The framework first calls setup(org.apache.hadoop.mapreduce.Mapper.Context), followed by map(Object, Object, Context) for each key/value pair in the InputSplit. Finally cleanup(Context) is called.
All intermediate values associated with a given output key are subsequently grouped by the framework, and passed to a Reducer to determine the final output. Users can control the sorting and grouping by specifying two key RawComparator classes.
The Mapper outputs are partitioned per Reducer. Users can control which keys (and hence records) go to which Reducer by implementing a custom Partitioner.
Users can optionally specify a combiner, via Job.setCombinerClass(Class), to perform local aggregation of the intermediate outputs, which helps to cut down the amount of data transferred from the Mapper to the Reducer.
Applications can specify if and how the intermediate outputs are to be compressed and which CompressionCodecs are to be used via the Configuration.
If the job has zero reduces then the output of the Mapper is directly written to the OutputFormat without sorting by keys.
- Mapper类的结构:
- 方法如下:
第一类:protected类型,用户根据实际需要进行覆写。
1) setup:每个任务执行前调用一次。
2) map:每个Key/Value对调用一次。
3) clearup:每个任务执行结束前调用一次。
第二类,运行的方法
run()方法,是Mapper类的入口,方法内部调用了setup()、map()、clearup()三个方法。
024_MapReduce中的基类Mapper和基类Reducer的更多相关文章
- 基类中定义的虚函数在派生类中重新定义时,其函数原型,包括返回类型、函数名、参数个数、参数类型及参数的先后顺序,都必须与基类中的原型完全相同 but------> 可以返回派生类对象的引用或指针
您查询的关键词是:c++primer习题15.25 以下是该网页在北京时间 2016年07月15日 02:57:08 的快照: 如果打开速度慢,可以尝试快速版:如果想更新或删除快照,可以投诉快照. ...
- 【Android进阶】为什么要创建Activity基类以及Activity基类中一般有哪些方法
现在也算是刚刚基本完成了自己的第一个商业项目,在开发的过程中,参考了不少人的代码风格,然而随着工作经验的积累,终于开始慢慢的了解到抽象思想在面向对象编程中的重要性,这一篇简单的介绍一下我的一点收获. ...
- 3.3 C++改变基类成员在派生类中的访问属性
参考:http://www.weixueyuan.net/view/6360.html 总结: 使用using声明可以改变基类成员在派生类中的访问属性. private: using book::se ...
- 图像处理中创建CDib类时无法选择基类类型时怎么办
图像处理中创建CDib类时无法选择基类类型时怎么办? 类的类型选择Generic Class 在下面的篮筐里输入CObject就行了
- 不可或缺 Windows Native (21) - C++: 继承, 组合, 派生类的构造函数和析构函数, 基类与派生类的转换, 子对象的实例化, 基类成员的隐藏(派生类成员覆盖基类成员)
[源码下载] 不可或缺 Windows Native (21) - C++: 继承, 组合, 派生类的构造函数和析构函数, 基类与派生类的转换, 子对象的实例化, 基类成员的隐藏(派生类成员覆盖基类成 ...
- 派生类地址比基类地址少4(子类与基类指针强行转换的时候,值居然会发生变化,不知道Delphi BCB是不是也这样) good
大家对虚表并不陌生,都知道每个含有虚函数的类对象都有1个虚指针,但是在现实使用中,却总是因为这而调试半天,才发现原来是虚指针惹的祸.我这几天在调试代码时候也中招了,我的问题是这样的,如下图,CTree ...
- Python的程序结构[2] -> 类/Class[1] -> 基类与继承
基类与继承 / Base Class and Inheritance Class 面向对象的特性使得 Python 中不可避免地需要使用到类和类的继承,类的继承可以使得代码很好的被重用.下面以一些代码 ...
- 派生类地址比基类地址少4(CDerived对象的起始地址存放的是虚表指针vptr,也就是子类的第一项内容。接下来的是基类的成员变量,接下来再是自身的成员变量)
大家对虚表并不陌生,都知道每个含有虚函数的类对象都有1个虚指针,但是在现实使用中,却总是因为这而调试半天,才发现原来是虚指针惹的祸.我这几天在调试代码时候也中招了,我的问题是这样的,如下图,CTree ...
- C++ - 派生类访问模板基类(templatized base class)命名
派生类访问模板基类(templatized base class)命名 本文地址: http://blog.csdn.net/caroline_wendy/article/details/239936 ...
随机推荐
- GoWeb编程之HelloWorld
使用Go实现我们的第一个Web服务器程序 package main import "net/http" import "fmt" //打印HelloWorld ...
- php 使用curl 将文件上传
<?php /** * curl文件上传 * @var struing $r_file 上传文件的路劲和文件名 */ function upload_file($r_f ...
- servelet 连接mysql
package helloworld; import java.io.IOException; import java.io.PrintWriter; import java.sql.*; impor ...
- Editor编辑器的一些用法
共有两个脚本,一个是有关Inspector面板的,一个是window的 using UnityEngine; using System.Collections; using UnityEditor; ...
- sqlserver tips
方括号内的表示一个对象名(视图,存储过程,表 等).列名:正常使用时,加不加一样,但是如果对象名是保留字的话,比如cascade,就必须加:不过建议不用保留字作为对象名 if object_id('[ ...
- cvsba-1.0.0/utils/test_cvsba.cpp:.......error: ‘numeric_limits’ is not a member of ‘std’... error: expected primary-expression before ‘float’....
cvsba库http://www.uco.es/investiga/grupos/ava/node/39,不知道怎么回事,记得以前编译没有错误,不知道作者是否更新了还是怎么着,新的现在有以下错误: 解 ...
- 自定制serilazry字段
在获取序列化返回值时候想要有时候我们需要生成我们需要的关联字段 class CourseSerializers(ModelSerializer): # 对于外键,one to one , choice ...
- Python数据驱动ddt
import ddtimport unittest """ddt模块包含了一个类的装饰器ddt和两个方法的装饰器: data:包含多个你想要传给测试用例的参数: file ...
- Android自定义Button字体颜色和背景颜色
http://blog.csdn.net/breeze666/article/details/7747649
- linux压缩、解压缩命令
tar -c: 建立压缩档案 -x:解压 -t:查看内容 -r:向压缩归档文件末尾追加文件 -u:更新原压缩包中的文件 这五个是独立的命令,压缩解压都要用到其中一个,可以和别的命令连用但只能用其中一个 ...