Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Optimize coverage and riak_kv_mrc_pipe using chashbin
  • Loading branch information
jtuple committed May 15, 2013
commit fdd8d02ebba83466ee65896c1670a8e4e0fcec3f
12 changes: 6 additions & 6 deletions src/riak_kv_coverage_filter.erl
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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([]) ->
Expand Down
16 changes: 2 additions & 14 deletions src/riak_kv_mrc_pipe.erl
Original file line number Diff line number Diff line change
Expand Up @@ -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).