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

    https://github.com/apache/spark/pull/369#discussion_r12621279
  
    --- Diff: core/src/main/scala/org/apache/spark/api/java/JavaRDD.scala ---
    @@ -150,6 +153,18 @@ class JavaRDD[T](val rdd: RDD[T])(implicit val 
classTag: ClassTag[T])
         rdd.setName(name)
         this
       }
    +
    +  /**
    +   * Return this RDD sorted by the given key function.
    +   */
    +  def sortBy[S](f: JFunction[T, S], ascending: Boolean, numPartitions: 
Int): JavaRDD[T] = {
    +    import scala.collection.JavaConverters._
    +    def fn = (x: T) => f.call(x)
    +    implicit val ordering = 
com.google.common.collect.Ordering.natural().asInstanceOf[Ordering[S]]
    --- End diff --
    
    Ordering.natural() returns an Ordering object, which implements the
    Comparator interface.
    
    
http://docs.guava-libraries.googlecode.com/git-history/release/javadoc/com/google/common/collect/Ordering.html#natural()
    
    
    On Tue, May 13, 2014 at 10:16 PM, Reynold Xin 
<[email protected]>wrote:
    
    > In core/src/main/scala/org/apache/spark/api/java/JavaRDD.scala:
    >
    > > @@ -150,6 +153,18 @@ class JavaRDD[T](val rdd: RDD[T])(implicit val 
classTag: ClassTag[T])
    > >      rdd.setName(name)
    > >      this
    > >    }
    > > +
    > > +  /**
    > > +   * Return this RDD sorted by the given key function.
    > > +   */
    > > +  def sortBy[S](f: JFunction[T, S], ascending: Boolean, numPartitions: 
Int): JavaRDD[T] = {
    > > +    import scala.collection.JavaConverters._
    > > +    def fn = (x: T) => f.call(x)
    > > +    implicit val ordering = 
com.google.common.collect.Ordering.natural().asInstanceOf[Ordering[S]]
    >
    > How does this actually work? Shouldn't natural() return a Comparator?
    >
    > —
    > Reply to this email directly or view it on 
GitHub<https://github.com/apache/spark/pull/369/files#r12621237>
    > .
    >


---
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.
---

Reply via email to