Github user JoshRosen commented on a diff in the pull request:

    https://github.com/apache/spark/pull/1791#discussion_r15916764
  
    --- Diff: python/pyspark/rdd.py ---
    @@ -811,23 +841,39 @@ def func(iterator):
     
             return self.mapPartitions(func).fold(zeroValue, combOp)
     
    -    def max(self):
    +    def max(self, comp=None):
             """
             Find the maximum item in this RDD.
     
    -        >>> sc.parallelize([1.0, 5.0, 43.0, 10.0]).max()
    +        >>> rdd = sc.parallelize([1.0, 5.0, 43.0, 10.0])
    +        >>> rdd.max()
             43.0
    +        >>> rdd.max(lambda a, b: cmp(str(a), str(b)))
    +        5.0
             """
    -        return self.reduce(max)
    +        if comp is not None:
    +            func = lambda a, b: a if comp(a, b) >= 0 else b
    +        else:
    +            func = max
    +
    +        return self.reduce(func)
     
    -    def min(self):
    +    def min(self, comp=None):
             """
             Find the minimum item in this RDD.
     
    -        >>> sc.parallelize([1.0, 5.0, 43.0, 10.0]).min()
    +        >>> rdd = sc.parallelize([1.0, 5.0, 43.0, 10.0])
    +        >>> rdd.min()
    +        1.0
    +        >>> rdd.min(lambda a, b: cmp(str(a), str(b)))
    --- End diff --
    
    In `max`, using this different comparator returns a different result.  We 
might want to pick an example here so that the two comparator settings yield 
different results.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to