Praveen, I just had a quick solution (might be stupid). In the first job, you can easily create adjacent list plus the reversed friendship from your input file. (you can use some special characters to distinguish these two types of output. E.g. "|"). The input is 1 2 1 3 2 4 2 5 3 6 The output will be like 1 2,3 2 |1 3 |1 2 4,5 4 |2 5 |2 3 6 6 |3
Then this output servers as the input for your next job. When the reducer sees both "2 |1" and "2 4,5", it will write "1 4,5". For "3 |1" and "3 6", it will write "1 6". Then the third job will combine all the friend-of-friend. Does it sound complicated? I do not know if there are easier way to do this. Wei -----Original Message----- From: James Seigel [mailto:ja...@tynt.com] Sent: Sunday, December 19, 2010 10:23 PM To: common-user@hadoop.apache.org Subject: Re: Friends of friends with MapReduce I may be wrong but it seems that you are approaching this problem like you would in the normal programming world and rightly so. Depending on the set of the data ( triangle square or other ), you could do some simple things like spit out the right side of your pair as the key and the left side as the value. Then all the pairs with 41 will show up at the same reducer and you can do you you magic there. Of course this depends on the setup of your data. Cheers James Sent from my mobile. Please excuse the typos. On 2010-12-19, at 7:29 PM, Praveen Bathala <pbatha...@gmail.com> wrote: > Hi, > > I am trying to write a MapReduce code to find friends of friends in a social network with MapReduce. > my data snippet : > > 1 41 > 1 7 > 1 100 > 2 64 > 2 65 > 2 42 > 2 86 > 3 54 > 3 24 > 3 16 > 3 43 > 4 39 > 4 52 > > Here map() goes through line by line, now I get "41" as friend to "1" and I want to go to all "41"'s to get his friends. how can I do that. > Can I jump to any line I need in Mapper class? > > Please, Help me with this... > > Thanks in advance > + Praveen