RDDBarrier.
mapPartitions
Returns a new RDD by applying a function to each partition of the wrapped RDD, where tasks are launched together in a barrier stage. The interface is the same as RDD.mapPartitions(). Please see the API doc there.
RDD.mapPartitions()
New in version 2.4.0.
a function to run on each partition of the RDD
indicates whether the input function preserves the partitioner, which should be False unless this is a pair RDD and the input
RDD
a new RDD by applying a function to each partition
See also
Notes
This API is experimental
Examples
>>> rdd = sc.parallelize([1, 2, 3, 4], 2) >>> def f(iterator): yield sum(iterator) >>> barrier = rdd.barrier() >>> barrier <pyspark.rdd.RDDBarrier ...> >>> barrier.mapPartitions(f).collect() [3, 7]