spark-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Xuefeng Wu <ben...@gmail.com>
Subject Re: What is the difference between map and flatMap
Date Wed, 12 Mar 2014 12:19:06 GMT
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.cto@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/吴雪峰  敬上

Mime
View raw message