Map vs flatMap in Spark?

Spark Map : 

A Spark map is a transformation operation in Apache Spark. It applies to each element of RDD and it returns the result as new RDD. In the Map operation developer can define his own custom business logic. The same logic will be applied to all the elements of RDD.

Spark FlatMap :

 FlatMap is a transformation operation. It applies to each element of RDD and it returns the result as new RDD. It is similar to Map, but FlatMap allows returning 0, 1 or more elements from map function.
In the FlatMap operation, a developer can define his own custom business logic. The same logic will be applied to all the elements of the RDD.

Ref : https://www.quora.com/What-is-the-difference-between-Map-and-FlatMap-in-Apache-Spark

Comments

Popular posts from this blog

What is Accumulator in Spark ?

Why Scala for Spark ?

What is SparkContext in Apache Spark?