Skip to content

Instantly share code, notes, and snippets.

@alexmoore
Created August 25, 2014 19:38
Show Gist options
  • Select an option

  • Save alexmoore/1429bebda4ebb924c4b9 to your computer and use it in GitHub Desktop.

Select an option

Save alexmoore/1429bebda4ebb924c4b9 to your computer and use it in GitHub Desktop.

Revisions

  1. alexmoore created this gist Aug 25, 2014.
    10 changes: 10 additions & 0 deletions find_primaries.erl
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,10 @@
    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.