当前位置:网站首页>(Spark调优~)算子的合理选择
(Spark调优~)算子的合理选择
2022-07-26 22:40:00 【不会打球的摄影师不是好程序员】
1.map与mappartition
1.map是对RDD中的每个元素作用上一个函数
2.mappartition是对每个分区作用上一个函数
如果遇到需要把数据写到数据库,一定要用mappartition
2.foreach 与foreachpartition
类似于map与mappartition
区别是:foreach是行动算子,map是转换算子
3.groupByKey与reduceByKey
1.groupByKey
所有数据都经过了shuffle。
2.reduceByKey
会先在map端做一个本地的聚合,然后聚合的数据进行shuffle操作(map端预聚合)
(优先采用这种方法)
4.collect算子
执行结果的数据全部梵高一个数组里(会导致OOM)慎用!
5.coalesce与repartition
两者的作用都是使分区数发生改变
1.coalesce算子
使分区数减少时不会有shuffle,(data.coalesce(1))
使分区数超过默认值时,会有shuffle
一般使用在多分区变少分区
2.repartition算子
repartition算子底层调用coalesce(shuffle = true),会有shuffle
边栏推荐
- Ah ah ah ah ah a
- JSCORE day_ 03(7.4)
- [CTF攻防世界] WEB区 关于备份的题目
- 6_ Gradient descent method
- flinksql 窗口提前触发
- 深入理解Golang - 闭包
- The detailed process of reinstalling AutoCAD after uninstallation and deleting the registry
- [ciscn2019 North China Day1 web5] cyberpunk
- 05 - 钓鱼网站的攻击与防御
- [Network Research Institute] attackers scan 1.6 million WordPress websites to find vulnerable plug-ins
猜你喜欢
随机推荐
Yolo of Darknet_ Forward of layer_ yolo_ Layer comments
MySql - 如何确定一个字段适合构建索引?
[RootersCTF2019]I_< 3_ Flask
[CISCN2019 总决赛 Day2 Web1]Easyweb
Detailed explanation of CSRF forged user request attack
[hongminggu CTF 2021] write_ shell
Promise basic usage 20211130
[Network Research Institute] attackers scan 1.6 million WordPress websites to find vulnerable plug-ins
Flink1.11 多并行度watermark测试
重学JSON.stringify
JSCORE day_01(6.30) RegExp 、 Function
forward和redirect的区别
Two or three things about redis
JSCORE day_05(7.6)
细说 call、apply 以及 bind 的区别和用法 20211031
基于Flink实时项目:用户行为分析(三:网站总浏览量统计(PV))
Ansible MySQL installation case record
SparkSql之编程方式
[b01lers2020]Welcome to Earth
Search engine realizes keyword highlighting


![[HarekazeCTF2019]encode_ and_ encode](/img/f5/c06523a1764717bdf2d91f069c9d77.png)

![[问题]yum资源被占用怎么办](/img/8d/50129fa1b1ef0aa0e968e6e6f20969.png)
![[ciscn2019 North China Day1 web5] cyberpunk](/img/84/b186adc8becfc9b3def7dfd8e4cd41.png)


![[b01lers2020]Welcome to Earth](/img/e7/c8c0427b95022fbdf7bf2128c469c0.png)
