当前位置:网站首页>干货丨MapReduce的工作流程是怎样的?
干货丨MapReduce的工作流程是怎样的?
2022-06-11 19:03:00 【Blue92120】
MapReduce编程模型开发简单且功能强大,专门为并行处理大规模数据量而设计,接下来,我们通过一张图来描述MapReduce的工作过程,如下图所示。

在图中,MapReduce的工作流程大致可以分为5步,具体如下:
1.分片、格式化数据源
输入Map阶段的数据源,必须经过分片和格式化操作。
分片操作:指的是将源文件划分为大小相等的小数据块(Hadoop2.x中默认128M),也就是分片(split),Hadoop会为每一个分片构建一个Map任务,并由该任务运行自定义的map()函数,从而处理分片里的每一条记录;
格式化操作:将划分好的分片(split)格式化为键值对<key,value>形式的数据,其中,key代表偏移量,value代表每一行内容。
2.执行MapTask
每个Map任务都有一个内存缓冲区(缓冲区大小100M),输入的分片(split)数据经过Map任务处理后的中间结果,会写入内存缓冲区中。如果写入的数据达到内存缓冲的阀值(80M),会启动一个线程将内存中的溢出数据写入磁盘,同时不影响map中间结果继续写入缓冲区。
在溢写过程中,MapReduce框架会对Key进行排序,如果中间结果比较大,会形成多个溢写文件,最后的缓冲区数据也会全部溢写入磁盘形成一个溢写文件,如果是多个溢写文件,则最后合并所有的溢写文件为一个文件。
3.执行Shuffle过程
MapReduce工作过程中,map阶段处理的数据如何传递给Reduce阶段,这是MapReduce框架中关键的一个过程,这个过程叫做Shuffle。
Shuffle会将MapTask输出的处理结果数据,分发给ReduceTask,并在分发的过程中,对数据按key进行分区和排序。
4.执行ReduceTask
输入ReduceTask的数据流是<key,{value list}>形式,用户可以自定义reduce()方法进行逻辑处理,最终以<key,value>的形式输出。
5.写入文件
MapReduce框架会自动把ReduceTask生成的<key,value>传入OutputFormat的write方法,实现文件的写入操作。
边栏推荐
- 【视频去噪】基于SALT实现视频去噪附Matlab代码
- leetcode:926. 将字符串翻转到单调递增【前缀和 + 模拟分析】
- Add your favorite background music
- 添加自己喜欢的背景音乐
- 软件开发的整体流程
- Swagger2简单使用
- cf:C. Restoring the Duration of Tasks【找规律】
- 为何TI的GPMC并口,更常被用于连接FPGA、ADC?我给出3个理由
- Teach you how to learn the first set and follow set!!!! Hematemesis collection!! Nanny level explanation!!!
- Niu Ke's question -- finding the least common multiple
猜你喜欢

北京邮电大学2023级工商管理硕士MBA(非全日制)已开启

The US inflation rate reached a 41 year high of 8.6%! High inflation fever? The stock and encryption markets fell first!

Cf:d. black and white stripe

手把手教你学会FIRST集和FOLLOW集!!!!吐血收藏!!保姆级讲解!!!

Replace the backbone of target detection (take the fast RCNN as an example)

Uni app Muke hot search project (I) production of tabbar
![[signal denoising] speech adaptive denoising based on nonlinear filter with matlab code](/img/fd/07cee3c51ac44ca40f730dd487aa20.png)
[signal denoising] speech adaptive denoising based on nonlinear filter with matlab code

In 2023, the MPAcc of School of management of Xi'an Jiaotong University approved the interview online in advance

ASEMI的MOS管24N50参数,24N50封装,24N50尺寸

Niu Ke brushes the question - no two
随机推荐
[solution] codeforces round 798 (Div. 2)
用户组的操作
開發中必備的文件的上傳與下載
Quanzhi T3 development board (4-core arm cortex-a7) - detailed explanation of logo display during system startup
MySQL in-depth and complete learning - stage 1 - overview of learning
KMP! You deserve it!!! Run directly!
Why is ti's GPMC parallel port more often used to connect FPGA and ADC? I give three reasons
Overall process of software development
Replace the backbone of target detection (take the fast RCNN as an example)
2022成年礼,致每一位高考学子
SQL注入漏洞学习之一:phpstudy集成环境搭建DVWA靶场
Dynamic explosion effect
BottomSheetDialog 使用详解,设置圆角、固定高度、默认全屏等
Visual slam lecture notes-10-2
Niu Ke's questions -- binary search tree and bidirectional linked list
Add your favorite background music
ASEMI的MOS管24N50参数,24N50封装,24N50尺寸
MBA, EMBA, MPa, MEM, pre interview (pre interview) time batch of national colleges and universities has been released (continuously updated) - Wendu Management Institute
Practice of Flink CDC in Dajian cloud warehouse
Crop disease detection using image processing technology and convolutional neural network (CNN)