rdd.flatMap { case (k, coll) => coll.map { elem => (elem, k) } } On Thu, Dec 4, 2014 at 1:26 AM, Yifan LI <iamyifa...@gmail.com> wrote:
> 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 > > > > > >