I have a park paired rdd (key, Array(value1, value2, value3.....)). what scala statement should I wrote? How could I flat this rdd and creating a new rdd : (key, value1), (key, value2), (key, value3)....
Asked
Active
Viewed 3,755 times
0
-
1probably just `rdd.flatMapValues(x=>x)` – mtoto Mar 31 '17 at 16:27
2 Answers
1
As @moto said, it is simply
rdd.flatMapValues(v => v)
A more verbose but arguably more readable option:
rdd.flatMap {
case (key, values) => values.map(v => key -> v)
}

Vidya
- 29,932
- 7
- 42
- 70