源码
def repartition(numPartitions: Int)(implicit ord: Ordering[T] = null): RDD[T] = withScope {
coalesce(numPartitions, shuffle = true)
}
- 底层调用coalesce()实现重分区操作
- 强制必须进行shuffle操作
repartition与coalesce的关系
- 都是用于重新设置分区数的算子
- repartition底层调用coalesce()实现重分区功能
- repartition强制必须进行shuffle操作
- coalesce根据参数决定是否进行shuffle操作