In a single phrase : if you understand what map() does and what a flatten()
might do, then flatMap() is like a map() followed by a flatten().

Like previously said, the concepts in themselves are not Spark specific.

Bertrand


On Wed, Mar 12, 2014 at 1:19 PM, Xuefeng Wu <ben...@gmail.com> wrote:

> 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