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 12:15:22 UTC

[couchdb] 02/02: 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 db7121dad54c5d9a8cc0d1e0e3b9884ac7e63d9c
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 | 10 +++++++++-
 src/fabric/src/fabric.erl                  |  9 ++++++++-
 src/mem3/src/mem3.erl                      |  3 ++-
 3 files changed, 19 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..b7e7f75 100644
--- a/src/couch_mrview/src/couch_mrview_util.erl
+++ b/src/couch_mrview/src/couch_mrview_util.erl
@@ -135,7 +135,15 @@ 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
+        ViewPartitioned /= undefined ->
+            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..55d2cd8 100644
--- a/src/fabric/src/fabric.erl
+++ b/src/fabric/src/fabric.erl
@@ -357,7 +357,14 @@ 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
+        ViewPartitioned /= undefined ->
+            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) ->