Saturday, November 22, 2014

Apache Spark User List - How to sort an RDD ?


Apache Spark User List - How to sort an RDD ?

Well it turns out you can use the takeOrdered function and create your
own Compare object

   object AceScoreOrdering extends Ordering[Record] {
      def compare(a:Record, b:Record) = a.score.ace_score compare
b.score.ace_score
    }

    val collected = dataset.takeOrdered(topN)(AceScoreOrdering)

Read full article from Apache Spark User List - How to sort an RDD ?

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.