我有RDD[(String, (Iterable[Int], Iterable[Coordinate]))]
我想做的是将Iterable[Int]
分解为元组,每个元组都像(String,Int,Iterable[Coordinate])
举个例子,我想改造:
('a',<1,2,3>,<(45.34,32.33),(45.36,32.34)>)
('b',<1>,<(46.64,32.66),(46.67,32.71)>)
到
('a',1,<(45.34,32.33),(45.36,32.34)>)
('a',2,<(45.34,32.33),(45.36,32.34)>)
('a',3,<(45.34,32.33),(45.36,32.34)>)
('b',1,<(46.64,32.66),(46.67,32.71)>)
Scala是如何完成的?
答案 0 :(得分:6)
尝试使用flatMap:
rdd.flatMap {case (v, i1, i2) => i1.map(i=>(v, i, i2)}