summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/dbs_cache.erl17
-rw-r--r--src/partitions.erl16
2 files changed, 19 insertions, 14 deletions
diff --git a/src/dbs_cache.erl b/src/dbs_cache.erl
index 96319802..f4faab3a 100644
--- a/src/dbs_cache.erl
+++ b/src/dbs_cache.erl
@@ -66,21 +66,26 @@ cache_dbs() ->
end.
cache_map(Id, Props) ->
- Map = couch_util:get_value(map, Props),
- lists:foreach(fun({[{node,Node},{b,Beg},{e,End}]}) ->
+ Map = couch_util:get_value(<<"map">>, Props),
+ lists:foreach(fun({[{<<"node">>,Node},{<<"b">>,Beg},{<<"e">>,End}]}) ->
Part = #shard{
name = partitions:shard_name(Beg, Id),
dbname = Id,
- node = Node,
+ node = to_atom(Node),
range = [Beg,End]
},
ets:insert(partitions, Part)
end, Map).
cache_nodes(Id, Props) ->
- Nodes = couch_util:get_value(nodes, Props),
- lists:foreach(fun({[{order,Order},{node, Node},{options,Opts}]}) ->
- ets:insert(memnodes, {Id, {Order, Node, Opts}})
+ Nodes = couch_util:get_value(<<"nodes">>, Props),
+ lists:foreach(fun({[{<<"order">>,Order},{<<"node">>, Node},{<<"options">>,Opts}]}) ->
+ ets:insert(memnodes, {Id, {Order, to_atom(Node), Opts}})
end, Nodes).
+to_atom(Node) when is_binary(Node) ->
+ list_to_atom(binary_to_list(Node));
+to_atom(Node) when is_atom(Node) ->
+ Node.
+
%{ok, ets:insert(dbs_cache, {Id, Props})};
diff --git a/src/partitions.erl b/src/partitions.erl
index 4fba0011..3e024264 100644
--- a/src/partitions.erl
+++ b/src/partitions.erl
@@ -37,10 +37,10 @@ hash(Item) ->
install_fullmap(DbName, Fullmap, FullNodes, Options) ->
{N,Q} = db_init_constants(Options),
Doc = {[{<<"_id">>,DbName},
- {map, jsonify(map, Fullmap)},
- {nodes, jsonify(nodes, FullNodes)},
- {n,N},
- {q,Q}]},
+ {<<"map">>, jsonify(<<"map">>, Fullmap)},
+ {<<"nodes">>, jsonify(<<"nodes">>, FullNodes)},
+ {<<"n">>,N},
+ {<<"q">>,Q}]},
write_db_doc(Doc).
for_key(DbName, Key) ->
@@ -153,13 +153,13 @@ make_map(AllNodes, [Node|RestNodes], [Part|RestParts], Acc) ->
% add a node/part combo to the Acc
make_map(AllNodes, RestNodes, RestParts, [{Node,Part}|Acc]).
-jsonify(map, Map) ->
+jsonify(<<"map">>, Map) ->
lists:map(fun(#shard{node=Node, range=[Beg,End]}) ->
- {[{node, Node}, {b, Beg}, {e, End}]}
+ {[{<<"node">>, Node}, {<<"b">>, Beg}, {<<"e">>, End}]}
end, Map);
-jsonify(nodes, Nodes) ->
+jsonify(<<"nodes">>, Nodes) ->
lists:map(fun({Order, Node, Options}) ->
- {[{order, Order}, {node, Node}, {options, Options}]}
+ {[{<<"order">>, Order}, {<<"node">>, Node}, {<<"options">>, Options}]}
end, Nodes).
write_db_doc(EDoc) ->