Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Optimize coverage and riak_kv_mrc_pipe using chashbin

  • Loading branch information...
commit fdd8d02ebba83466ee65896c1670a8e4e0fcec3f 1 parent cc35687
@jtuple jtuple authored
Showing with 8 additions and 20 deletions.
  1. +6 −6 src/riak_kv_coverage_filter.erl
  2. +2 −14 src/riak_kv_mrc_pipe.erl
View
12 src/riak_kv_coverage_filter.erl
@@ -66,13 +66,13 @@ build_filter(Bucket, ItemFilterInput, FilterVNode) ->
%% Compose a key filtering function for the VNode
ItemFilter;
(ItemFilter == none) -> % only vnode filtering required
- {ok, Ring} = riak_core_ring_manager:get_my_ring(),
- PrefListFun = build_preflist_fun(Bucket, Ring),
+ {ok, CHBin} = riak_core_ring_manager:get_chash_bin(),
+ PrefListFun = build_preflist_fun(Bucket, CHBin),
%% Create a VNode filter
compose_filter(FilterVNode, PrefListFun);
true -> % key and vnode filtering
- {ok, Ring} = riak_core_ring_manager:get_my_ring(),
- PrefListFun = build_preflist_fun(Bucket, Ring),
+ {ok, CHBin} = riak_core_ring_manager:get_chash_bin(),
+ PrefListFun = build_preflist_fun(Bucket, CHBin),
%% Create a filter for the VNode
compose_filter(FilterVNode, PrefListFun, ItemFilter)
end.
@@ -112,10 +112,10 @@ build_item_filter(FilterInput) ->
%% @private
-build_preflist_fun(Bucket, Ring) ->
+build_preflist_fun(Bucket, CHBin) ->
fun(Key) ->
ChashKey = riak_core_util:chash_key({Bucket, Key}),
- riak_core_ring:responsible_index(ChashKey, Ring)
+ chashbin:responsible_index(ChashKey, CHBin)
end.
compose([]) ->
View
16 src/riak_kv_mrc_pipe.erl
@@ -1057,17 +1057,5 @@ random_constant_hash()->
%% work, plus all work assigned to their predecessor); perhaps
%% something that also skips a random number of up vnodes in the
%% next version?
- {ok, Ring} = riak_core_ring_manager:get_my_ring(),
- Preflist = riak_core_ring:preflist(Random, Ring),
- {Partition, _Node} = first_up(Preflist),
- riak_pipe_vnode:hash_for_partition(Partition).
-
-%% this will fail if: this node() is a new member, owning no
-%% partitions or not having started its riak_pipe service yet, and all
-%% other nodes are down
-first_up(Preflist) ->
- UpSet = ordsets:from_list(riak_core_node_watcher:nodes(riak_pipe)),
- hd(lists:dropwhile(fun({_P, Node}) ->
- not ordsets:is_element(Node, UpSet)
- end,
- Preflist)).
+ {Partition, _Node} = riak_core_apl:first_up(Random, riak_pipe),
+ riak_pipe_vnode:hash_for_partition(Partition).
Please sign in to comment.
Something went wrong with that request. Please try again.