couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rnew...@apache.org
Subject [20/48] mem3 commit: updated refs/heads/windsor-merge to ff02b9a
Date Fri, 01 Aug 2014 09:11:06 GMT
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/windsor-merge
Commit: 4b6f001df3a5724d3d679dd1d8cc4af502a4108a
Parents: e30659b
Author: Robert Newson <robert.newson@cloudant.com>
Authored: Wed Jul 31 11:14:15 2013 +0100
Committer: Robert Newson <rnewson@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) ->


Mime
View raw message