Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Upgrade to new mem3 shards API

BugzId: 13414
  • Loading branch information...
commit 28edb0e1e8dac1ab972591df9d4f7e6e769c76ce 1 parent 8a6e6fe
Paul J. Davis davisp authored
Showing with 8 additions and 8 deletions.
  1. +1 −1  README.md
  2. +2 −2 src/fabric.erl
  3. +5 −5 src/fabric_view_changes.erl
2  README.md
View
@@ -2,7 +2,7 @@
Fabric is a collection of proxy functions for [CouchDB][1] operations in a cluster. These functions are used in [BigCouch][2] as the remote procedure endpoints on each of the cluster nodes.
-For example, creating a database is a straightforward task in standalone CouchDB, but for BigCouch, each node that will store a shard/partition for the database needs to receive and execute a fabric function. The node handling the request also needs to compile the results from each of the nodes and respond accordingly to the client.
+For example, creating a database is a straightforward task in standalone CouchDB, but for BigCouch, each node that will store a shard for the database needs to receive and execute a fabric function. The node handling the request also needs to compile the results from each of the nodes and respond accordingly to the client.
Fabric is used in conjunction with 'Rexi' which is also an application within BigCouch.
4 src/fabric.erl
View
@@ -55,14 +55,14 @@ all_dbs() ->
-spec all_dbs(Prefix::iodata()) -> {ok, [binary()]}.
all_dbs(Prefix) when is_binary(Prefix) ->
Length = byte_size(Prefix),
- MatchingDbs = ets:foldl(fun(#shard{dbname=DbName}, Acc) ->
+ MatchingDbs = mem3:fold_shards(fun(#shard{dbname=DbName}, Acc) ->
case DbName of
<<Prefix:Length/binary, _/binary>> ->
[DbName | Acc];
_ ->
Acc
end
- end, [], partitions),
+ end, []),
{ok, lists:usort(MatchingDbs)};
%% @equiv all_dbs(list_to_binary(Prefix))
10 src/fabric_view_changes.erl
View
@@ -262,12 +262,12 @@ unpack_seqs(Packed, DbName) ->
do_unpack_seqs(Opaque, DbName) ->
% TODO relies on internal structure of fabric_dict as keylist
lists:map(fun({Node, [A,B], Seq}) ->
- Match = #shard{node=Node, range=[A,B], dbname=DbName, _ = '_'},
- case ets:match_object(partitions, Match) of
- [Shard] ->
+ case mem3:get_shard(DbName, Node, [A,B]) of
+ {ok, Shard} ->
{Shard, Seq};
- [] ->
- {Match, Seq} % will be replaced in find_replacement_shards
+ {error, not_found} ->
+ PlaceHolder = #shard{node=Node, range=[A,B], dbname=DbName, _='_'},
+ {PlaceHolder, Seq} % will be replaced in find_replacement_shards
end
end, binary_to_term(couch_util:decodeBase64Url(Opaque))).

2 comments on commit 28edb0e

Bob Dionne

{error, duplicates} is also returned from this function call

Paul J. Davis
Owner

I left that out on purpose so that it'll blow up. Nothing I can really do to handle it at this layer or really do much about it. It maintains the same behavior as before because the case clause only matched [Shard] and [].

Please sign in to comment.
Something went wrong with that request. Please try again.