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/16 11:50:55 UTC

[couchdb] 04/05: tidier

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 25c4438dd1d81ea2871a61cdd422c7b6c4f87117
Author: Robert Newson <rn...@apache.org>
AuthorDate: Mon Jul 16 12:34:42 2018 +0100

    tidier
---
 src/couch/src/couch_db_engine.erl          | 2 +-
 src/couch_mrview/src/couch_mrview_util.erl | 7 +------
 src/fabric/src/fabric.erl                  | 2 +-
 src/mem3/src/mem3.erl                      | 5 +++++
 4 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/src/couch/src/couch_db_engine.erl b/src/couch/src/couch_db_engine.erl
index efd221f..11f9149 100644
--- a/src/couch/src/couch_db_engine.erl
+++ b/src/couch/src/couch_db_engine.erl
@@ -182,7 +182,7 @@
 
 % Whether the database is partitioned by the user's choice of
 % document id
--callback get_partitioned(DbHAndle::db_handle()) ->
+-callback get_partitioned(DbHandle::db_handle()) ->
             Partitioned::boolean().
 
 
diff --git a/src/couch_mrview/src/couch_mrview_util.erl b/src/couch_mrview/src/couch_mrview_util.erl
index ce8f4eb..5bb25b4 100644
--- a/src/couch_mrview/src/couch_mrview_util.erl
+++ b/src/couch_mrview/src/couch_mrview_util.erl
@@ -281,12 +281,7 @@ 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 = case couch_db_engine:get_prop(Db, partitioned) of
-        {ok, true} -> true;
-        {ok, false} -> false;
-        {error, no_value} -> false
-    end,
+    Partitioned = couch_db_engine:get_partitioned(Db),
 
     State#mrst{
         fd=Fd,
diff --git a/src/fabric/src/fabric.erl b/src/fabric/src/fabric.erl
index 59fbb2b..00513a7 100644
--- a/src/fabric/src/fabric.erl
+++ b/src/fabric/src/fabric.erl
@@ -355,7 +355,7 @@ query_view(DbName, Options, DDoc, ViewName, Callback, Acc0, QueryArgs0) ->
     {ok, #mrst{views=Views, language=Lang}} =
         couch_mrview_util:ddoc_to_mrst(Db, DDoc),
 
-    Partitioned = mem3:is_partitioned(hd(mem3:shards(Db))), % hideous
+    Partitioned = mem3:is_partitioned(Db),
 
     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 7cdadba..4b022ed 100644
--- a/src/mem3/src/mem3.erl
+++ b/src/mem3/src/mem3.erl
@@ -337,10 +337,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(#shard{opts=Opts}) ->
     is_partitioned(Opts);
+
 is_partitioned(#ordered_shard{opts=Opts}) ->
     is_partitioned(Opts);
+
 is_partitioned(Opts) when is_list(Opts) ->
     lists:member(partitioned, Opts).