pyspark.RDD.coalesce ¶
-
RDD.
coalesce
( numPartitions : int , shuffle : bool = False ) → pyspark.rdd.RDD [ T ] [source] ¶ -
返回一个新的RDD,该RDD被缩减为 numPartitions 个分区。
新增于版本 1.0.0。
- Parameters
-
- numPartitions int, optional
-
新
RDD
中的分区数量 - shuffle bool, optional, default False
-
是否添加一个洗牌步骤
- Returns
另请参阅
示例
>>> sc.parallelize([1, 2, 3, 4, 5], 3).glom().collect() [[1], [2, 3], [4, 5]] >>> sc.parallelize([1, 2, 3, 4, 5], 3).coalesce(1).glom().collect() [[1, 2, 3, 4, 5]]