Ripple/riak-client doesn't split a bunch of links into multiple
headers for you, right?

I'm trying the new associations feature which works great btw, but if
i'm limited to 100/150 links or a horrible workaround (in terms of
client code), I'd probably be better off storing that in an associated
document and resorting to map-reduce.

Something like (in Javascript):

var map = function(v) {
  var doc = Riak.mapValuesJson(v)[0];
  return doc.following.map(function(key) { return ['users', key] })
}

db
  .map(map)
  // [ eventually a .link({})  here ]
  .map("Riak.mapValuesJson")
  .run([['user_relations', 'user1']])()

This approach also makes more sense to me now, it allows me to
decouple relationships from the users docs, leaving those lightweight
for other operations.

Thanks,
Francisco

2010/6/30 Sean Cribbs <s...@basho.com>:
> Francisco,
>
> The answer is to make your client submit multiple Link headers, which Riak 
> will join together. Watch what happens if I do that with curl:
>
> $ curl -v -X PUT http://localhost:8098/riak/test/one -H "Content-Type: 
> text/plain" -d 'Hello,world' -H 'Link: </riak/test/two>; riaktag="next"' -H 
> 'Link: </riak/test/zero>; riaktag="previous"'
> * About to connect() to localhost port 8098 (#0)
> *   Trying ::1... Connection refused
> *   Trying fe80::1... Connection refused
> *   Trying 127.0.0.1... connected
> * Connected to localhost (127.0.0.1) port 8098 (#0)
>> PUT /riak/test/one HTTP/1.1
>> User-Agent: curl/7.19.7 (universal-apple-darwin10.0) libcurl/7.19.7 
>> OpenSSL/0.9.8l zlib/1.2.3
>> Host: localhost:8098
>> Accept: */*
>> Content-Type: text/plain
>> Link: </riak/test/two>; riaktag="next"
>> Link: </riak/test/zero>; riaktag="previous"
>> Content-Length: 11
>>
> < HTTP/1.1 204 No Content
> < Vary: Accept-Encoding
> < Server: MochiWeb/1.1 WebMachine/1.7 (participate in the frantic)
> < Date: Wed, 30 Jun 2010 14:02:55 GMT
> < Content-Type: text/plain
> < Content-Length: 0
> <
> * Connection #0 to host localhost left intact
> * Closing connection #0
>
> $ curl -v http://localhost:8098/riak/test/one
> * About to connect() to localhost port 8098 (#0)
> *   Trying ::1... Connection refused
> *   Trying fe80::1... Connection refused
> *   Trying 127.0.0.1... connected
> * Connected to localhost (127.0.0.1) port 8098 (#0)
>> GET /riak/test/one HTTP/1.1
>> User-Agent: curl/7.19.7 (universal-apple-darwin10.0) libcurl/7.19.7 
>> OpenSSL/0.9.8l zlib/1.2.3
>> Host: localhost:8098
>> Accept: */*
>>
> < HTTP/1.1 200 OK
> < X-Riak-Vclock: a85hYGBgzGDKBVIsjAzzwzOYEhnzWBn6T80/ypcFAA==
> < Vary: Accept-Encoding
> < Server: MochiWeb/1.1 WebMachine/1.7 (participate in the frantic)
> < Link: </riak/test/two>; riaktag="next", </riak/test/zero>; 
> riaktag="previous", </riak/test>; rel="up"
> < Last-Modified: Wed, 30 Jun 2010 14:02:55 GMT
> < ETag: 3uMSzFK8guChtOhlvtx99g
> < Date: Wed, 30 Jun 2010 14:03:32 GMT
> < Content-Type: text/plain
> < Content-Length: 11
> <
> * Connection #0 to host localhost left intact
> * Closing connection #0
> Hello,world
>
> Sean Cribbs <s...@basho.com>
> Developer Advocate
> Basho Technologies, Inc.
> http://basho.com/
>
> On Jun 29, 2010, at 10:07 PM, francisco treacy wrote:
>
>> Hi all,
>>
>> We're developing social features in our app that involve Twitter-like
>> relations between users.
>>
>> As we have a 'users' bucket, the initial implementation is to add
>> links to following users (and link followers back) in order to create
>> a two-way relationship.
>>
>> User A  ==== following ====> User B
>> User B ==== follower ====> User A
>>
>> This makes sense and turns out to work perfectly fine, but I am
>> concerned with hitting limits rather soon. For some reason (webmachine
>> related?) there is an 8k limit for the Link header. I verified this
>> (documents with 8192b+ Link headers won't be persisted).
>>
>> Considering average key sizes and the typical usecase of our app, this
>> means we can store somewhere between 100 and 150 links - max. Given we
>> store different types of links (not only to other users), it'll
>> definitely won't work for us.
>>
>> So I guess my question is two-fold:
>> (a) is this limit intended? if not, how can it be eluded?
>> (b) are there better ways of modeling this scenario?
>>
>> I was thinking along the lines of storing this 'followers/following'
>> data in an associated document instead, and feeding a link phase keys
>> coming from a map function.
>>
>> Those of you who tried implementing Twitter in Riak :) ...how did you
>> approach the problem?
>>
>> Francisco
>>
>> _______________________________________________
>> riak-users mailing list
>> riak-users@lists.basho.com
>> http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com
>
>

_______________________________________________
riak-users mailing list
riak-users@lists.basho.com
http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com

Reply via email to