2

Can anyone familier with Riak explain how to do a link-walk to find common friends among two people (eg. just like Facebook's common friends)? Also, the computation requirement should ideally be minimal - ie. the server does not have to go through great length do do calculations.

I'm thinking of putting all 'persons' in a "people" bucket, and each 'person' will have a friends link (this is like a one-to-many relationship), then for each 'person' is reversed relationship-linked back to the other person (this is like a one-to-one relationship). I think it is possible to do this efficiently and calculation/result will be instantly available, but just can't figure it out.

(Alright, I have not exactly started real-coding with Riak, so a more thorough explanation on Riak's link walking feature would be appreciated.)

Thanks!

ikevin8me
  • 4,253
  • 5
  • 44
  • 84

1 Answers1

0

I see two possible solutions:

  1. MapReduce job with approximately this scenario:
    • Two inputs with people A and B being compared
    • Link phase fetching their friends IDs
    • Map them to tuples {FriendID, 1}
    • Reduce sum the 1s
    • Reduce filter where sum = 2
    • %% Last few steps can be combined into one if necessary
  2. Just issue a link-walking query for each person and intersect returned sets on client - a bit ugly, but works.
Ivan Blinkov
  • 2,466
  • 15
  • 17