couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kxe...@apache.org
Subject [1/4] couch commit: updated refs/heads/master to ad867d4
Date Fri, 30 Jan 2015 18:10:49 GMT
Repository: couchdb-couch
Updated Branches:
  refs/heads/master 8e473e107 -> ad867d4ad


Use namespace argument to select correct tree for the enum_docs request

COUCHDB-1145


Project: http://git-wip-us.apache.org/repos/asf/couchdb-couch/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-couch/commit/a0ad4898
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-couch/tree/a0ad4898
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-couch/diff/a0ad4898

Branch: refs/heads/master
Commit: a0ad48986bf73449c5ae88d80b573aa3a27ae8a7
Parents: 2a45cb0
Author: ILYA Khlopotov <iilyak@ca.ibm.com>
Authored: Tue Dec 16 12:42:28 2014 -0800
Committer: ILYA Khlopotov <iilyak@ca.ibm.com>
Committed: Thu Dec 18 12:33:21 2014 -0800

----------------------------------------------------------------------
 src/couch_db.erl | 22 +++++++++++++++++++---
 1 file changed, 19 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-couch/blob/a0ad4898/src/couch_db.erl
----------------------------------------------------------------------
diff --git a/src/couch_db.erl b/src/couch_db.erl
index 86b6558..59f72cf 100644
--- a/src/couch_db.erl
+++ b/src/couch_db.erl
@@ -1210,12 +1210,28 @@ enum_docs_since(Db, SinceSeq, InFun, Acc, Options) ->
             [{start_key, SinceSeq + 1} | Options]),
     {ok, enum_docs_since_reduce_to_count(LastReduction), AccOut}.
 
-enum_docs(Db, InFun, InAcc, Options) ->
+enum_docs(Db, InFun, InAcc, Options0) ->
+    {NS, Options} = extract_namespace(Options0),
+    enum_docs(Db, NS, InFun, InAcc, Options).
+
+enum_docs(Db, undefined, InFun, InAcc, Options) ->
     FoldFun = skip_deleted(InFun),
     {ok, LastReduce, OutAcc} = couch_btree:fold(
         Db#db.id_tree, FoldFun, InAcc, Options),
-    {ok, enum_docs_reduce_to_count(LastReduce), OutAcc}.
-
+    {ok, enum_docs_reduce_to_count(LastReduce), OutAcc};
+enum_docs(Db, <<"_local">>, InFun, InAcc, Options) ->
+    FoldFun = skip_deleted(InFun),
+    {ok, _LastReduce, OutAcc} = couch_btree:fold(
+        Db#db.local_tree, FoldFun, InAcc, Options),
+    {ok, 0, OutAcc}.
+
+extract_namespace(Options0) ->
+    case proplists:split(Options0, [namespace]) of
+        {[[{namespace, NS}]], Options} ->
+            {NS, Options};
+        {_, Options} ->
+            {undefined, Options}
+    end.
 
 %%% Internal function %%%
 open_doc_revs_int(Db, IdRevs, Options) ->


Mime
View raw message