上一篇讲了RDD,这篇讲RDD的shuffle一些知识与诸君分享
什么是shuffle,以及为什么需要shuffle?
shuffle中文翻译为洗牌,需要shuffle的原因是: 具有共同特征的数据汇聚到一个计算节点上进行计算
spark中shuffle的分类
主要分三种:
1、hashshuffle : 默认不排序,直接进行shuffle
2、sortshuffle :默认先进行排序。在shuffle
3、钨丝(Tungsten) shuffle : 在sortshuffle的基础上对内存进行了优化
那么在RDD算子中那些算子是shuffle算子呢?
一般by,bykey型的算子都要经过shuffle过程
如
reduceByKey, | groupByKey,
sortByKey, countByKey,
join(未分组数据), cogroup,leftOuterjoin,
rightOuterjoin, coalesce(参数为true时),
repartition, combineByKey,
aggregateByKey, groupBy,
distinct, sortByKey,sortBy,
countByKey, intersection(交集),subtract(差集)