It is the same concept with other FP API,
you could learn it from Scala collection map and flatmap

http://www.brunton-spall.co.uk/post/2011/12/02/map-map-and-flatmap-in-scala/


Spark doc:

*map*(*func*) Return a new distributed dataset formed by passing each
element of the source through a function *func*. *flatMap*(*func*)
Similar to map, but each input item can be mapped to 0 or more output items
(so *func* should return a Seq rather than a single item).




On Wed, Mar 12, 2014 at 7:50 PM, goi cto <goi....@gmail.com> wrote:

> Hi,
>
> Can someone explain to me the difference between map and flatMap and what
> is a good use case for each?
>
> --
> Eran | CTO
>



-- 

~Yours, Xuefeng Wu/吴雪峰  敬上

Reply via email to