如何将此RDD [(Long,Iterable [String])]转换为...
(852403,Set(PT0000094043, PT0000097083, PT0000036162))
(357331,Set(PT0000068829, PT0000094042, PT0000066859))
RDD [(Long,String)]是这样的吗?
(852403, PT0000094043)
(852403, PT0000097083)
(852403, PT0000036162)
(357331, PT0000068829)
(357331, PT0000094042)
(357331, PT0000066859)
答案 0 :(得分:2)
尝试flatMapValues
:
rdd.flatMapValues(identity)
或flatMap
:
rdd.flatMap{ case (k, vs) => vs.map(v => (k, v)) }