spark-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Yifan LI <iamyifa...@gmail.com>
Subject Re: map function
Date Thu, 04 Dec 2014 12:09:34 GMT
Thanks, Paolo and Mark. :)


> On 04 Dec 2014, at 11:58, Paolo Platter <paolo.platter@agilelab.it> wrote:
> 
> Hi,
> 
> rdd.flatMap( e => e._2.map( i => ( i, e._1)))
> 
> Should work, but I didn't test it so maybe I'm missing something.
> 
> Paolo
> 
> Inviata dal mio Windows Phone
> Da: Yifan LI <mailto:iamyifanli@gmail.com>
> Inviato: ‎04/‎12/‎2014 09:27
> A: user@spark.apache.org <mailto:user@spark.apache.org>
> Oggetto: map function 
> 
> Hi,
> 
> I have a RDD like below:
> (1, (10, 20))
> (2, (30, 40, 10))
> (3, (30))
> …
> 
> Is there any way to map it to this:
> (10,1)
> (20,1)
> (30,2)
> (40,2)
> (10,2)
> (30,3)
> …
> 
> generally, for each element, it might be mapped to multiple.
> 
> Thanks in advance! 
> 
> 
> Best,
> Yifan LI
> 
> 
> 
> 
> 


Mime
View raw message