python - 如何对键的转换进行reduceByKey并返回整个记录
问题描述
我分别有一个带有[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)
我想要完成的是获得这样的RDD (String,Int)
:
("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
但它不起作用。是否有捷径可寻?
解决方案
推荐阅读
- android - 尝试将 Android 设备用作 GATT 服务器时出现 GATT_READ_NOT_PERMIT 错误
- ruby-on-rails - 从acts_as_paranoid 迁移到paranoia gem
- python - Python中的递归排列
- reactjs - React:如何覆盖状态
- python - 如何在无头模式下选择窗口?
- google-cloud-platform - 谷歌云构建触发静态站点:“ascii”编解码器无法编码字符
- javascript - 在 SuiteScript 中创建实体组
- javascript - IndexedDB:使用方法 add 多次执行函数 - 没有新的 DB 条目
- android - 在 Android 中开源基于语音的 Indoor Turn-by-turn 导航
- c - X11/Xlib:虚拟键盘输入和键盘映射同步问题