viirya commented on a change in pull request #35252:
URL: https://github.com/apache/spark/pull/35252#discussion_r798241351
##########
File path: python/pyspark/rdd.py
##########
@@ -1534,15 +1768,23 @@ def top(self, num, key=None):
[4, 3, 2]
"""
- def topIterator(iterator):
+ def topIterator(iterator: Iterable[T]) -> Iterable[List[T]]:
yield heapq.nlargest(num, iterator, key=key)
- def merge(a, b):
+ def merge(a: List[T], b: List[T]) -> List[T]:
return heapq.nlargest(num, a + b, key=key)
return self.mapPartitions(topIterator).reduce(merge)
- def takeOrdered(self, num, key=None):
+ @overload
+ def takeOrdered(self: "RDD[S]", num: int) -> "List[S]":
Review comment:
Hmm, why for `top`, it is:
`def top(self: "RDD[S]", num: int) -> List["S"]:`
but here it isn't:
`def takeOrdered(self: "RDD[S]", num: int) -> List["S"]:`
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]