diff options
author | Adam Kocoloski <adam@cloudant.com> | 2010-07-01 11:44:51 -0400 |
---|---|---|
committer | Adam Kocoloski <adam@cloudant.com> | 2010-08-12 01:23:16 -0400 |
commit | 5f7ff55f41acd820b5aea51fbff6dc3b61a0222c (patch) | |
tree | 826d8fec7ce853269d1d7d7fdbc24e7d81599d1c /src/mem3_cache.erl | |
parent | 68a6934ae52b5876054a525411ef69523b6b9a03 (diff) |
converter from Doc to #shard{} is more general
Diffstat (limited to 'src/mem3_cache.erl')
-rw-r--r-- | src/mem3_cache.erl | 16 |
1 files changed, 1 insertions, 15 deletions
diff --git a/src/mem3_cache.erl b/src/mem3_cache.erl index 532a023a..b17db1a2 100644 --- a/src/mem3_cache.erl +++ b/src/mem3_cache.erl @@ -79,23 +79,9 @@ changes_callback({change, {Change}, _}, _) -> ?LOG_ERROR("missing partition table for ~s: ~p", [DbName, Reason]); {Doc} -> ets:delete(partitions, DbName), - cache_partition_table(DbName, Doc) + ets:insert(partitions, mem3_util:build_shards(DbName, Doc)) end end, {ok, couch_util:get_value(seq, Change)}; changes_callback(timeout, _) -> {ok, nil}. - -cache_partition_table(DbName, Doc) -> - ets:insert(partitions, lists:map(fun({Map}) -> - Begin = couch_util:get_value(<<"b">>, Map), - #shard{ - name = mem3_util:shard_name(Begin, DbName), - dbname = DbName, - node = to_atom(couch_util:get_value(<<"node">>, Map)), - range = [Begin, couch_util:get_value(<<"e">>, Map)] - } - end, couch_util:get_value(<<"map">>, Doc, {[]}))). - -to_atom(Node) when is_binary(Node) -> - list_to_atom(binary_to_list(Node)). |