当前位置: 首页 > article >正文

MR-图解

1、不是所有的MR都适合combine

1.1、map端统计出了不同班级的每个学生的年龄

如:(class1, 14)表示class1班的一个学生的年龄是14岁。

第一个map任务:

class1 14
class1 15
class1 16
class2 10

第二个map任务:

class1 16
class2 10
class2 11

平均年龄:

class1: ((14+15+16)+16)/4 = 61/4 = 15.25
class2: (10+10+11)/3 = 10.333
1.2、若强制使用combine的话。

第一个map任务:

class1 14
class1 15
class1 16
class2 10
==>平均值:
class1: (14+15+16)/3 = 15
class2: 10/1 = 10

第二个map任务:

class1 16
class2 10
class2 11
==>平均值:
class1: 16/1 = 16
class2: (10+11)/2  =10.5

平均年龄:

==>汇总求平均值:
class1: (15+16)/2  =15.5
class2: (10+10.5) = 10.25

比对结果:

class1: 15.25不等于15.5
class2: 10.333不等于10.25
1.3、结论:并非所有MR都适合combine操作

2、reduce端merge 排序 分组

第一个map输出

(hadoop,1)
(hadoop,1)
(hive,1)

第二个map输出

(hadoop,1)
(hive,1)

第三个map输出

(hadoop,1)
(hive,1)
(hive,1)
–>merge
(hadoop,1)
(hadoop,1)
(hive,1)
(hadoop,1)
(hive,1)
(hadoop,1)
(hive,1)
(hive,1)
–>排序
(hadoop,1)
(hadoop,1)
(hadoop,1)
(hadoop,1)

(hive,1)
(hive,1)
(hive,1)
(hive,1)
–>分组
一组
(hadoop,1)
(hadoop,1)
(hadoop,1)
(hadoop,1)
二组
(hive,1)
(hive,1)
(hive,1)
(hive,1)
–>每组调用一次reduce方法
(hadoop,1)
(hadoop,1)  -> hadoop, Iterable(1,1,1,1) -> reduce(hadoop, Iterable(1,1,1,1), context){...}
(hadoop,1)
(hadoop,1)

⭐️3、wordcount+combine过程

在这里插入图片描述

⭐️4、wordcount shuffle

在这里插入图片描述

5、grouping

在这里插入图片描述

6、自定义OutputFormat

在这里插入图片描述


http://www.kler.cn/a/566285.html

相关文章:

  • AutoMQ:无需 Cruise Control 实现 Kafka 的自动分区再平衡
  • Linux-基本指令1
  • 【原创】Open WebUI 本地部署
  • 嵌入式仿真实验教学平台比Proteus更具有教学优势
  • Bonito
  • Android Studio - 查看类的继承结构(通过快捷键查看、通过菜单导航查看)
  • 日期时间 API
  • 删除变慢问题
  • 蓝桥杯好题推荐----高精度乘法
  • 【Kubernetes】对资源进行PATCH
  • 蓝桥备赛(四)- 数组(下)
  • Docker小游戏 | 使用Docker部署star-battle太空飞船射击小游戏
  • 60个SQL注入Payload清单集合
  • H13-821 V3.0 HCIP 云服务架构题题库
  • Geek卸载软件安装使用教程
  • MySQL双主复制
  • 设置同一个局域网内远程桌面Ubuntu
  • 腾讯云扩容记录
  • 怎么让IDEA启动项目添加到Service里面
  • 【大数据】ClickHouse常见的错误及解决方式