Skip to content

Instantly share code, notes, and snippets.

@alexmoore
Created August 25, 2014 19:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alexmoore/1429bebda4ebb924c4b9 to your computer and use it in GitHub Desktop.
Save alexmoore/1429bebda4ebb924c4b9 to your computer and use it in GitHub Desktop.
FindPrimaries = fun(Bucket, Key, Ring) ->
BKey = {Bucket,Key},
DocIdx = riak_core_util:chash_key(BKey),
BucketProps = riak_core_bucket:get_bucket(Bucket, Ring),
[NValue] = [Y || {X1, Y} <- BucketProps, n_val == X1],
CHBin = chashbin:create(riak_core_ring:chash(Ring)),
Itr = chashbin:iterator(DocIdx, CHBin),
{Primaries, Itr2} = chashbin:itr_pop(3, Itr),
Primaries
end.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment