Github user ash211 commented on a diff in the pull request:
https://github.com/apache/spark/pull/369#discussion_r12621569
--- 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 --
Thank you! I'm not incredibly familiar with Java/Scala interactions so
would appreciate the assistance. Also, didn't know Scala had an Ordering.
Using Guava for the default comparator was based on the
`sortByKey(Boolean)` method in `JavaPairRDD.scala`
On Tue, May 13, 2014 at 10:35 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]]
>
> I will submit a pr to fix these.
>
> â
> Reply to this email directly or view it on
GitHub<https://github.com/apache/spark/pull/369/files#r12621500>
> .
>
---
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.
---