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/07/18 13:41:10 UTC
[couchdb] 01/01: A view defaults to the same partitioned-ness of
the db
This is an automated email from the ASF dual-hosted git repository.
rnewson pushed a commit to branch user-partitioned-dbs-wip
in repository https://gitbox.apache.org/repos/asf/couchdb.git
commit e1cbd16a3c3cb4b21931dd84d3c182d984a5f5dd
Author: Robert Newson <rn...@apache.org>
AuthorDate: Wed Jul 18 13:15:04 2018 +0100
A view defaults to the same partitioned-ness of the db
---
src/couch_mrview/src/couch_mrview_util.erl | 12 +++++++++++-
src/fabric/src/fabric.erl | 11 ++++++++++-
src/mem3/src/mem3.erl | 3 ++-
3 files changed, 23 insertions(+), 3 deletions(-)
diff --git a/src/couch_mrview/src/couch_mrview_util.erl b/src/couch_mrview/src/couch_mrview_util.erl
index d997352..3f454cf 100644
--- a/src/couch_mrview/src/couch_mrview_util.erl
+++ b/src/couch_mrview/src/couch_mrview_util.erl
@@ -135,7 +135,17 @@ ddoc_to_mrst(DbName, #doc{id=Id, body={Fields}}) ->
{DesignOpts} = proplists:get_value(<<"options">>, Fields, {[]}),
SeqIndexed = proplists:get_value(<<"seq_indexed">>, DesignOpts, false),
KeySeqIndexed = proplists:get_value(<<"keyseq_indexed">>, DesignOpts, false),
- Partitioned = proplists:get_value(<<"partitioned">>, DesignOpts, false),
+
+ DbPartitioned = mem3:is_partitioned(DbName),
+ ViewPartitioned = proplists:get_value(<<"partitioned">>, DesignOpts),
+ Partitioned = if
+ not DbPartitioned ->
+ false;
+ is_boolean(ViewPartitioned) ->
+ ViewPartitioned;
+ true ->
+ DbPartitioned
+ end,
{RawViews} = couch_util:get_value(<<"views">>, Fields, {[]}),
BySrc = lists:foldl(MakeDict, dict:new(), RawViews),
diff --git a/src/fabric/src/fabric.erl b/src/fabric/src/fabric.erl
index c7a47b0..aa8c699 100644
--- a/src/fabric/src/fabric.erl
+++ b/src/fabric/src/fabric.erl
@@ -357,7 +357,16 @@ query_view(DbName, Options, DDoc, ViewName, Callback, Acc0, QueryArgs0) ->
{ok, #mrst{views=Views, language=Lang, design_opts=DesignOpts}} =
couch_mrview_util:ddoc_to_mrst(Db, DDoc),
- Partitioned = couch_util:get_value(<<"partitioned">>, DesignOpts, false),
+ DbPartitioned = mem3:is_partitioned(Db),
+ ViewPartitioned = couch_util:get_value(<<"partitioned">>, DesignOpts),
+ Partitioned = if
+ not DbPartitioned ->
+ false;
+ is_boolean(ViewPartitioned) ->
+ ViewPartitioned;
+ true ->
+ DbPartitioned
+ end,
QueryArgs1 = couch_mrview_util:set_view_type(QueryArgs0, View, Views),
QueryArgs2 = couch_mrview_util:set_view_options(QueryArgs1, partitioned, Partitioned),
diff --git a/src/mem3/src/mem3.erl b/src/mem3/src/mem3.erl
index 8a71b26..d79e904 100644
--- a/src/mem3/src/mem3.erl
+++ b/src/mem3/src/mem3.erl
@@ -337,7 +337,8 @@ engine(Opts) when is_list(Opts) ->
[]
end.
-is_partitioned(DbName) when is_binary(DbName) ->
+is_partitioned(DbName0) when is_binary(DbName0) ->
+ DbName = dbname(DbName0),
is_partitioned(mem3:shards(DbName));
is_partitioned(Shards) when is_list(Shards) ->