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/17 12:39:26 UTC

[couchdb] branch user-partitioned-dbs-wip updated (fd3aa7e -> 726208e)

This is an automated email from the ASF dual-hosted git repository.

rnewson pushed a change to branch user-partitioned-dbs-wip
in repository https://gitbox.apache.org/repos/asf/couchdb.git.


    from fd3aa7e  fix bug that forced all dbs to be partitioned
     new ba58da3  move partition flag into view options
     new bbd263f  tidier
     new 726208e  Prohibit include_docs=true for partitioned views

The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../fixtures/3b835456c235b1827e012e25666152f3.view | Bin 4192 -> 0 bytes
 src/couch_mrview/src/couch_mrview_index.erl        |   4 +++-
 src/couch_mrview/src/couch_mrview_util.erl         |  21 +++++++++++----------
 src/fabric/src/fabric.erl                          |   4 ++--
 src/mem3/src/mem3.erl                              |  10 +++++-----
 src/mem3/src/mem3_shards.erl                       |   2 +-
 6 files changed, 22 insertions(+), 19 deletions(-)
 delete mode 100644 src/couch/test/fixtures/3b835456c235b1827e012e25666152f3.view


[couchdb] 03/03: Prohibit include_docs=true for partitioned views

Posted by rn...@apache.org.
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 726208e5e8a2b59dbc97e3f6503d8938364df57f
Author: Robert Newson <rn...@apache.org>
AuthorDate: Tue Jul 17 13:10:02 2018 +0100

    Prohibit include_docs=true for partitioned views
---
 src/couch_mrview/src/couch_mrview_util.erl | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/src/couch_mrview/src/couch_mrview_util.erl b/src/couch_mrview/src/couch_mrview_util.erl
index e50ab77..9f11a89 100644
--- a/src/couch_mrview/src/couch_mrview_util.erl
+++ b/src/couch_mrview/src/couch_mrview_util.erl
@@ -535,9 +535,10 @@ validate_args(Args) ->
         _ -> mrverror(<<"Invalid value for `inclusive_end`.">>)
     end,
 
-    case {Args#mrargs.view_type, Args#mrargs.include_docs} of
-        {red, true} -> mrverror(<<"`include_docs` is invalid for reduce">>);
-        {_, ID} when is_boolean(ID) -> ok;
+    case {Args#mrargs.partitioned, Args#mrargs.view_type, Args#mrargs.include_docs} of
+        {true, _, true} -> mrverror(<<"`include_docs` is invalid for partitioned views">>);
+        {_, red, true} -> mrverror(<<"`include_docs` is invalid for reduce">>);
+        {_, _, ID} when is_boolean(ID) -> ok;
         _ -> mrverror(<<"Invalid value for `include_docs`">>)
     end,
 


[couchdb] 02/03: tidier

Posted by rn...@apache.org.
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 bbd263fb0c9d024f49e5bad475390c18b103a8eb
Author: Robert Newson <rn...@apache.org>
AuthorDate: Mon Jul 16 15:23:00 2018 +0100

    tidier
---
 src/mem3/src/mem3.erl        | 10 +++++-----
 src/mem3/src/mem3_shards.erl |  2 +-
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/src/mem3/src/mem3.erl b/src/mem3/src/mem3.erl
index 4b022ed..8a71b26 100644
--- a/src/mem3/src/mem3.erl
+++ b/src/mem3/src/mem3.erl
@@ -338,15 +338,15 @@ engine(Opts) when is_list(Opts) ->
     end.
 
 is_partitioned(DbName) when is_binary(DbName) ->
-    lists:all(fun is_partitioned/1, mem3:shards(DbName));
+    is_partitioned(mem3:shards(DbName));
+
+is_partitioned(Shards) when is_list(Shards) ->
+    lists:all(fun is_partitioned/1, Shards);
 
 is_partitioned(#shard{opts=Opts}) ->
-    is_partitioned(Opts);
+    lists:member(partitioned, Opts);
 
 is_partitioned(#ordered_shard{opts=Opts}) ->
-    is_partitioned(Opts);
-
-is_partitioned(Opts) when is_list(Opts) ->
     lists:member(partitioned, Opts).
 
 
diff --git a/src/mem3/src/mem3_shards.erl b/src/mem3/src/mem3_shards.erl
index 18ed82e..5b0b608 100644
--- a/src/mem3/src/mem3_shards.erl
+++ b/src/mem3/src/mem3_shards.erl
@@ -82,7 +82,7 @@ for_docid(DbName, DocId, Options) ->
             load_shards_from_disk(DbName, DocId);
         Shards0 ->
             gen_server:cast(?MODULE, {cache_hit, DbName}),
-            Options1 = case mem3:is_partitioned(hd(Shards0)) of
+            Options1 = case mem3:is_partitioned(Shards0) of
                 true  -> [partitioned];
                 false -> []
             end,


[couchdb] 01/03: move partition flag into view options

Posted by rn...@apache.org.
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 ba58da3634bf64875343a0689490c942cf361af2
Author: Robert Newson <rn...@apache.org>
AuthorDate: Mon Jul 16 15:19:12 2018 +0100

    move partition flag into view options
---
 .../test/fixtures/3b835456c235b1827e012e25666152f3.view  | Bin 4192 -> 0 bytes
 src/couch_mrview/src/couch_mrview_index.erl              |   4 +++-
 src/couch_mrview/src/couch_mrview_util.erl               |  14 +++++++-------
 src/fabric/src/fabric.erl                                |   4 ++--
 4 files changed, 12 insertions(+), 10 deletions(-)

diff --git a/src/couch/test/fixtures/3b835456c235b1827e012e25666152f3.view b/src/couch/test/fixtures/3b835456c235b1827e012e25666152f3.view
deleted file mode 100644
index 9c67648..0000000
Binary files a/src/couch/test/fixtures/3b835456c235b1827e012e25666152f3.view and /dev/null differ
diff --git a/src/couch_mrview/src/couch_mrview_index.erl b/src/couch_mrview/src/couch_mrview_index.erl
index 5d285d6..2d462d9 100644
--- a/src/couch_mrview/src/couch_mrview_index.erl
+++ b/src/couch_mrview/src/couch_mrview_index.erl
@@ -38,10 +38,12 @@ get(update_options, #mrst{design_opts = Opts}) ->
     LocalSeq = couch_util:get_value(<<"local_seq">>, Opts, false),
     SeqIndexed = couch_util:get_value(<<"seq_indexed">>, Opts, false),
     KeySeqIndexed = couch_util:get_value(<<"keyseq_indexed">>, Opts, false),
+    Partitioned = couch_util:get_value(<<"partitioned">>, Opts, false),
     if IncDesign -> [include_design]; true -> [] end
         ++ if LocalSeq -> [local_seq]; true -> [] end
         ++ if KeySeqIndexed -> [keyseq_indexed]; true -> [] end
-        ++ if SeqIndexed -> [seq_indexed]; true -> [] end;
+        ++ if SeqIndexed -> [seq_indexed]; true -> [] end
+        ++ if Partitioned -> [partitioned]; true -> [] end;
 get(fd, #mrst{fd = Fd}) ->
     Fd;
 get(language, #mrst{language = Language}) ->
diff --git a/src/couch_mrview/src/couch_mrview_util.erl b/src/couch_mrview/src/couch_mrview_util.erl
index 5bb25b4..e50ab77 100644
--- a/src/couch_mrview/src/couch_mrview_util.erl
+++ b/src/couch_mrview/src/couch_mrview_util.erl
@@ -135,6 +135,7 @@ 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),
 
     {RawViews} = couch_util:get_value(<<"views">>, Fields, {[]}),
     BySrc = lists:foldl(MakeDict, dict:new(), RawViews),
@@ -155,7 +156,8 @@ ddoc_to_mrst(DbName, #doc{id=Id, body={Fields}}) ->
         language=Language,
         design_opts=DesignOpts,
         seq_indexed=SeqIndexed,
-        keyseq_indexed=KeySeqIndexed
+        keyseq_indexed=KeySeqIndexed,
+        partitioned=Partitioned
     },
     SigInfo = {Views, Language, DesignOpts, couch_index_util:sort_lib(Lib)},
     {ok, IdxState#mrst{sig=crypto:hash(md5, term_to_binary(SigInfo))}}.
@@ -281,7 +283,6 @@ init_state(Db, Fd, State, Header) ->
 
     OpenViewFun = fun(St, View) -> open_view(Db, Fd, Lang, St, View) end,
     Views2 = lists:zipwith(OpenViewFun, ViewStates, Views),
-    Partitioned = couch_db_engine:get_partitioned(Db),
 
     State#mrst{
         fd=Fd,
@@ -290,8 +291,7 @@ init_state(Db, Fd, State, Header) ->
         purge_seq=PurgeSeq,
         id_btree=IdBtree,
         log_btree=LogBtree,
-        views=Views2,
-        partitioned=Partitioned
+        views=Views2
     }.
 
 open_view(_Db, Fd, Lang, ViewState, View) ->
@@ -554,14 +554,14 @@ validate_args(Args) ->
         _ -> mrverror(<<"Invalid value for `sorted`.">>)
     end,
 
-    case {Args#mrargs.partitioned, Args#mrargs.partition} of
+    case {Args#mrargs.partitioned == true, Args#mrargs.partition} of
         {true, undefined} ->
             mrverror(<<"`partition` parameter is mandatory for queries to this database.">>);
         {true, _Partition} ->
             ok;
-        {undefined, undefined} ->
+        {false, undefined} ->
             ok;
-        {undefined, _Partition} ->
+        {false, _Partition} ->
             mrverror(<<"`partition` parameter is not supported in this database.">>)
     end,
     Args.
diff --git a/src/fabric/src/fabric.erl b/src/fabric/src/fabric.erl
index 308de64..c7a47b0 100644
--- a/src/fabric/src/fabric.erl
+++ b/src/fabric/src/fabric.erl
@@ -354,10 +354,10 @@ query_view(DbName, Options, DDoc, ViewName, Callback, Acc0, QueryArgs0) ->
     false ->
         ok
     end,
-    {ok, #mrst{views=Views, language=Lang}} =
+    {ok, #mrst{views=Views, language=Lang, design_opts=DesignOpts}} =
         couch_mrview_util:ddoc_to_mrst(Db, DDoc),
 
-    Partitioned = mem3:is_partitioned(Db),
+    Partitioned = couch_util:get_value(<<"partitioned">>, DesignOpts, false),
 
     QueryArgs1 = couch_mrview_util:set_view_type(QueryArgs0, View, Views),
     QueryArgs2 = couch_mrview_util:set_view_options(QueryArgs1, partitioned, Partitioned),