You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by rn...@apache.org on 2014/08/28 14:22:48 UTC
[28/50] mem3 commit: updated refs/heads/master to 64c0c74
Move rotate_list to mem3_util
Project: http://git-wip-us.apache.org/repos/asf/couchdb-mem3/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-mem3/commit/4b6f001d
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-mem3/tree/4b6f001d
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-mem3/diff/4b6f001d
Branch: refs/heads/master
Commit: 4b6f001df3a5724d3d679dd1d8cc4af502a4108a
Parents: e30659b
Author: Robert Newson <ro...@cloudant.com>
Authored: Wed Jul 31 11:14:15 2013 +0100
Committer: Robert Newson <rn...@apache.org>
Committed: Wed Jul 23 18:46:26 2014 +0100
----------------------------------------------------------------------
src/mem3.erl | 8 +-------
src/mem3_util.erl | 10 +++++++++-
2 files changed, 10 insertions(+), 8 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb-mem3/blob/4b6f001d/src/mem3.erl
----------------------------------------------------------------------
diff --git a/src/mem3.erl b/src/mem3.erl
index af17d5c..02e929f 100644
--- a/src/mem3.erl
+++ b/src/mem3.erl
@@ -262,16 +262,10 @@ group_by_proximity(Shards, ZoneMap) ->
choose_ushards(DbName, Shards) ->
Groups0 = group_by_range(Shards),
- Groups1 = [rotate_list(term_to_binary({DbName, R}), order_shards(G))
+ Groups1 = [mem3_util:rotate_list({DbName, R}, order_shards(G))
|| {R, G} <- Groups0],
[hd(G) || G <- Groups1].
-rotate_list(_Key, []) ->
- [];
-rotate_list(Key, List) ->
- {H, T} = lists:split(erlang:crc32(Key) rem length(List), List),
- T ++ H.
-
order_shards([#ordered_shard{}|_]=OrderedShards) ->
lists:keysort(#ordered_shard.order, OrderedShards);
order_shards(UnorderedShards) ->
http://git-wip-us.apache.org/repos/asf/couchdb-mem3/blob/4b6f001d/src/mem3_util.erl
----------------------------------------------------------------------
diff --git a/src/mem3_util.erl b/src/mem3_util.erl
index 5c8c989..8e17393 100644
--- a/src/mem3_util.erl
+++ b/src/mem3_util.erl
@@ -15,7 +15,7 @@
-export([hash/1, name_shard/2, create_partition_map/5, build_shards/2,
n_val/2, to_atom/1, to_integer/1, write_db_doc/1, delete_db_doc/1,
shard_info/1, ensure_exists/1, open_db_doc/1]).
--export([owner/2, is_deleted/1]).
+-export([owner/2, is_deleted/1, rotate_list/2]).
%% do not use outside mem3.
-export([build_ordered_shards/2, downcast/1]).
@@ -238,6 +238,14 @@ is_deleted(Change) ->
Else
end.
+rotate_list(_Key, []) ->
+ [];
+rotate_list(Key, List) when not is_binary(Key) ->
+ rotate_list(term_to_binary(Key), List);
+rotate_list(Key, List) ->
+ {H, T} = lists:split(erlang:crc32(Key) rem length(List), List),
+ T ++ H.
+
downcast(#shard{}=S) ->
S;
downcast(#ordered_shard{}=S) ->