Map and FlatMap
#sparkday20of30
What is the difference between map and flatmap in Spark?
Visual Example:
Using?map:
Input RDD:?[1, 2, 3]
Transformation:?x => [x, x+1]
Output RDD:?[[1, 2], [2, 3], [3, 4]]
Using?flatMap:
Input RDD:?[1, 2, 3]
Transformation:?x => [x, x+1]
Output RDD:?[1, 2, 2, 3, 3, 4]