我有一个带有[String, Int]
类型列的RDD。
RDD值类似于:
("A x",3)
("A y",4)
("A z",1)
("B y",2)
("C w",5)
("C y",2)
("E x",1)
("E z",3)
我要完成的工作是获得一个像(String,Int)
这样的RDD:
("A y",4) #among the key's that contains y, (A y) has the max value
("A x",3) #among the key's that contains x, (A x) has the max value
("E z",3) #among the key's that contains z, (E z) has the max value
("C w",5) #among the key's that contains w, (C w) has the max value
我在flatMap
中尝试了一个循环概念(通过使用计数器),但是它不起作用。
有没有简单的方法可以做到这一点?