将 RDD 中的元组分解为两个元组

Break tuple in RDD to two tuples

我有一个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 是怎么做的?

尝试使用平面地图:

rdd.flatMap {case (v, i1, i2) => i1.map(i=>(v, i, i2)}