Advertisement
Dundre32

Untitled

May 1st, 2020
974
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Scala 0.44 KB | None | 0 0
  1.  
  2. //Group elements by key, convert the iterable to list, then sort them in descending order, take the first 200 element
  3. //Sort the result RDD by key
  4. val sortedRdd = calcChiSquares.groupByKey().map{case(k,v) => (k ,
  5.                                                               v.toList.sortWith(_.split(":")(1).toDouble > _.split(":")(1).toDouble)
  6.                                                               .take(200).mkString(" "))}.sortByKey()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement