Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions python/pyspark/rdd.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,12 @@ def flatMap(self, f, preservesPartitioning=False):
def func(s, iterator): return chain.from_iterable(imap(f, iterator))
return self.mapPartitionsWithIndex(func, preservesPartitioning)

def partitions(self):
"""
Get the array of partitions of this RDD, taking into account whether the RDD is checkpointed or not.
"""
return self._jrdd.splits()
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, I'm not sure that having a Python method return a Java object is right thing to do. Or is it?

len(rdd.partitions()) works as you would expect, and so does rdd.partitions().size(), but I'm not sure how else this method might be used.


def mapPartitions(self, f, preservesPartitioning=False):
"""
Return a new RDD by applying a function to each partition of this RDD.
Expand Down