Link walking with Erlang riak client

Morgan Segalis msegalis at gmail.com
Wed Jun 20 07:58:41 EDT 2012


Hi Eric,

Thank you for your answer.

Yeah apparently, Links are not the Eldorado I though it was.
In my head it was a pointer to another record, and accessing it would be faster than regular requests…

I'm not really looking for more than 100 friends in one user's list really. (Except the rare user that will have 1000 or more friends).
When you say "a limited length", I'm not sure what you are referring… ?

Actually, more than checking if A and B are friends, I was looking for getting fast Information about friends, e.g. :

- retrieve all friend's information by Link Walking, like : A/B/name A/C/name A/D/name …

But it seems that I would not be as fast as I though ?

Thank you,

Morgan.

Le 19 juin 2012 à 19:48, Eric Moritz a écrit :

> Links may not be the most appropriate way to model a set of associated
> users.  They have a limited length and both the user data and the
> links have to be saved at the same time.
> 
> What you can do is emulate a set using a separate bucket and secondary indexes.
> 
> So basically the bucket would look like this:
> 
> So if I'm a friend of yours,
> 
> PUT /buckets/friends/keys/eric-morgan
> x-riak-index-friend_id_bin: morgan
> x-riak-index-user_id_bin: eric
> Content-Type: application/json
> 
> {"user_id": "eric", "friend_id": "morgan"}
> 
> Then you can fetch a set of my friends by doing a 2i query for the
> bucket friends and the index
> user_id.
> 
> If you want to a set of all the people that have friended you, do a 2i
> query on friend_id with the value "morgan".
> 
> You can quickly see if we're mutual friends by fetching:
> 
> /buckets/friends/keys/eric-morgan and /buckets/friends/keys/morgan-eric.
> 
> If both are found, then we're mutual friends.
> 
> Eric.
> 
> On Tue, Jun 19, 2012 at 12:35 PM, Morgan Segalis <msegalis at gmail.com> wrote:
>> Hi everyone !
>> 
>> I'm looking for a NoSQL solution to get ride of MySQL.
>> In this particular issue, I think that Riak is one of the top of my choices in order to do what I'm looking for.
>> 
>> I would like to store all my users into Riak.
>> I understand that Riak is document oriented, so that's great for getting every information really fast from one user.
>> One of the feature I'm really interested in, are Links.
>> 
>> Links seems to be a great way for me to create association between users…
>> 
>> When A adds B, I create a link from A to B.
>> When B accepts A's invitation, I create a link from B to A.
>> 
>> If links are not both ways, e.g. A to B to A, message can not go through (B who didn't accept A should not get its message yet)
>> 
>> My server is coded in Erlang, I have checked the Erlang riak client, and I didn't see something as simple as the HTTP use of Links in the demo.
>> 
>> 1 - Are Link walking in Erlang fast & easy ?
>> 2 - Is it possible to check fast if A -> B -> A (still in Erlang)? ('->' represents Links)
>> 
>> Thank you for your help !
>> 
>> Morgan.
>> _______________________________________________
>> riak-users mailing list
>> riak-users at lists.basho.com
>> http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com





More information about the riak-users mailing list