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 2018/08/13 21:35:17 UTC
[couchdb] 01/06: Select only the shard containing the partition,
if specified
This is an automated email from the ASF dual-hosted git repository.
rnewson pushed a commit to branch user-partitioned-dbs-6
in repository https://gitbox.apache.org/repos/asf/couchdb.git
commit 5fde7a5664b8eb74542dbe5384df3438453d9278
Author: Robert Newson <rn...@apache.org>
AuthorDate: Mon Aug 6 19:16:09 2018 +0100
Select only the shard containing the partition, if specified
---
src/fabric/src/fabric_util.erl | 1 -
src/fabric/src/fabric_view.erl | 32 ++++++++++++++++++++++++++++----
2 files changed, 28 insertions(+), 5 deletions(-)
diff --git a/src/fabric/src/fabric_util.erl b/src/fabric/src/fabric_util.erl
index dd4b80d..4d2f2c7 100644
--- a/src/fabric/src/fabric_util.erl
+++ b/src/fabric/src/fabric_util.erl
@@ -64,7 +64,6 @@ stream_start(Workers0, Keypos, StartFun, Replacements) ->
Timeout = request_timeout(),
case rexi_utils:recv(Workers0, Keypos, Fun, Acc, Timeout, infinity) of
{ok, #stream_acc{workers=Workers}} ->
- true = fabric_view:is_progress_possible(Workers),
AckedWorkers = fabric_dict:fold(fun(Worker, From, WorkerAcc) ->
rexi:stream_start(From),
[Worker | WorkerAcc]
diff --git a/src/fabric/src/fabric_view.erl b/src/fabric/src/fabric_view.erl
index 69f4290..b4b8a8c 100644
--- a/src/fabric/src/fabric_view.erl
+++ b/src/fabric/src/fabric_view.erl
@@ -309,10 +309,34 @@ index_of(X, [X|_Rest], I) ->
index_of(X, [_|Rest], I) ->
index_of(X, Rest, I+1).
-get_shards(DbName, #mrargs{stable=true}) ->
- mem3:ushards(DbName);
-get_shards(DbName, #mrargs{stable=false}) ->
- mem3:shards(DbName).
+
+get_shards(DbName, #mrargs{} = Args) ->
+ Partitioned = couch_mrview_util:get_extra(Args, partitioned),
+ Partition = partition_docid(Args),
+ case {Args#mrargs.stable, Partitioned, Partition} of
+ {true, false, _} ->
+ mem3:ushards(DbName);
+ {true, true, undefined} ->
+ mem3:ushards(DbName);
+ {true, true, Partition} ->
+ mem3:ushards(DbName, Partition);
+ {false, false, _} ->
+ mem3:shards(DbName);
+ {false, true, undefined} ->
+ mem3:shards(DbName);
+ {false, true, Partition} ->
+ mem3:shards(DbName, Partition)
+ end.
+
+% create a fake docid within the specified partition.
+partition_docid(Args) ->
+ case couch_mrview_util:get_extra(Args, partition) of
+ undefined ->
+ undefined;
+ Partition when is_binary(Partition) ->
+ <<Partition/binary, ":foo">>
+ end.
+
maybe_update_others(DbName, DDoc, ShardsInvolved, ViewName,
#mrargs{update=lazy} = Args) ->