Spark中的Shuffle算子

官网的话

什么是Shuffle
In Spark, data is generally not distributed across partitions to be in the necessary place for a specific operation.
During computations, a single task will operate on a single partition - thus, 
to organize all the data for a single reduceByKey reduce task to execute, 
Spark needs to perform an all-to-all operation. It must read from all partitions to find all the values for all keys, 
and then bring together values across partitions to compute the final result for each key - this is called the shuffle.

我直接复制了整段话,其实用概括起来就是:

把不同节点的数据拉取到同一个节点的过程就叫做Shuffle

有哪些Shuffle算子
Operations which can cause a shuffle include 
repartition operations like repartition and coalesce, 
‘ByKey operations (except for counting) like groupByKey and reduceByKey, 
and join operations like cogroup and join.

这一句话完美总结了Spark中Shuffle算子的分类:

  • 重分区算子
    (repartition ,coalesce)
  • ByKey算子
    (groupByKey ,reduceByKey)
  • Join算子
    (cogroup ,join)

详细总结三类Shuffle算子

其实官网写那几个就是最常用的了

  • 重分区算子
  1. repartition
  2. coalesce
  • ByKey算子
  1. groupByKey
  2. reduceByKey
  3. aggregateByKey
  4. combineByKey
  5. sortByKey
  6. sortBy
  • Join算子
  1. cogroup
  2. join
  3. leftOuterJoin
  4. intersection
  5. subtract
  6. subtractByKey
    (姑且把后面三个也放到Join类算子)

后记

官网说了三类,这里再加一类:

  • 去重算子
    distinct
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

SunnyRivers

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值