How to find max value in pair RDD?

前端 未结 4 1310
攒了一身酷
攒了一身酷 2020-12-01 14:30

I have a spark pair RDD (key, count) as below

Array[(String, Int)] = Array((a,1), (b,2), (c,1), (d,3))

How to find the key with highest co

4条回答
  •  青春惊慌失措
    2020-12-01 15:23

    Spark RDD's are more efficient timewise when they are left as RDD's and not turned into Arrays

    strinIntTuppleRDD.reduce((x, y) => if(x._2 > y._2) x else y)
    

提交回复
热议问题