Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Spark - sort by value with a JavaPairRDD

Working with apache spark using Java. I got an JavaPairRDD<String,Long> and I want to sort this dataset by its value. However, it seems that there only is sortByKey method in it. How could I sort it by the value of Long type?

like image 984
chrisTina Avatar asked Dec 26 '22 01:12

chrisTina


1 Answers

dataset.mapToPair(x -> x.swap()).sortByKey(false).mapToPair(x -> x.swap()).take(100)

like image 102
Atul Soman Avatar answered Feb 05 '23 14:02

Atul Soman