Skip to content

Instantly share code, notes, and snippets.

@angrycub
Created June 18, 2015 00:27
Show Gist options
  • Save angrycub/f4324f64b6ab2bc8825f to your computer and use it in GitHub Desktop.
Save angrycub/f4324f64b6ab2bc8825f to your computer and use it in GitHub Desktop.
Get a Preflist for a bucket key
Preflist = fun(Bucket,Key) ->
BKey = {Bucket,Key},
{ok, Ring} = riak_core_ring_manager:get_my_ring(),
DocIdx = riak_core_util:chash_key(BKey),
BucketProps = riak_core_bucket:get_bucket(Bucket, Ring),
[NValue] = [Y || {X1, Y} <- BucketProps, n_val == X1],
UpNodes = riak_core_node_watcher:nodes(riak_kv),
Preflist2 = riak_core_apl:get_apl_ann(DocIdx, NValue, Ring, UpNodes),
[IndexNode || {IndexNode, _Type} <- Preflist2]
end.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment