I want to understand in which scenario that I should use FlatMap or Map. The documentation did not seem clear to me.
I still do not understand in which scenario I should use the transformation of FlatMap or Map.
Could someone give me an example so I can understand their difference?
I understand the difference of FlatMap vs Map in Spark, and however not sure if there any similarity?
A
Map
transform, maps from aPCollection
of N elements into anotherPCollection
of N elements.A
FlatMap
transform maps aPCollections
of N elements into N collections of zero or more elements, which are then flattened into a singlePCollection
.As a simple example, the following happens:
Whereas: