couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rand...@apache.org
Subject svn commit: r1152406 - in /couchdb/branches/1.1.x/src/couchdb: couch_db.erl couch_view.erl
Date Sat, 30 Jul 2011 00:37:33 GMT
Author: randall
Date: Sat Jul 30 00:37:32 2011
New Revision: 1152406

URL: http://svn.apache.org/viewvc?rev=1152406&view=rev
Log:
Backport of r1152398 from trunk

Fix COUCHDB-1076 - views skip empty btree branches

Modified:
    couchdb/branches/1.1.x/src/couchdb/couch_db.erl
    couchdb/branches/1.1.x/src/couchdb/couch_view.erl

Modified: couchdb/branches/1.1.x/src/couchdb/couch_db.erl
URL: http://svn.apache.org/viewvc/couchdb/branches/1.1.x/src/couchdb/couch_db.erl?rev=1152406&r1=1152405&r2=1152406&view=diff
==============================================================================
--- couchdb/branches/1.1.x/src/couchdb/couch_db.erl (original)
+++ couchdb/branches/1.1.x/src/couchdb/couch_db.erl Sat Jul 30 00:37:32 2011
@@ -271,7 +271,8 @@ get_db_info(Db) ->
     {ok, InfoList}.
 
 get_design_docs(#db{fulldocinfo_by_id_btree=Btree}=Db) ->
-    {ok,_, Docs} = couch_btree:fold(Btree,
+    {ok, _, Docs} = couch_view:fold(
+        #view{btree=Btree},
         fun(#full_doc_info{id= <<"_design/",_/binary>>}=FullDocInfo, _Reds, AccDocs)
->
             {ok, Doc} = couch_db:open_doc_int(Db, FullDocInfo, []),
             {ok, [Doc | AccDocs]};
@@ -976,7 +977,8 @@ enum_docs_since(Db, SinceSeq, InFun, Acc
     {ok, enum_docs_since_reduce_to_count(LastReduction), AccOut}.
 
 enum_docs(Db, InFun, InAcc, Options) ->
-    {ok, LastReduce, OutAcc} = couch_btree:fold(Db#db.fulldocinfo_by_id_btree, InFun, InAcc,
Options),
+    {ok, LastReduce, OutAcc} = couch_view:fold(
+        #view{btree=Db#db.fulldocinfo_by_id_btree}, InFun, InAcc, Options),
     {ok, enum_docs_reduce_to_count(LastReduce), OutAcc}.
 
 % server functions

Modified: couchdb/branches/1.1.x/src/couchdb/couch_view.erl
URL: http://svn.apache.org/viewvc/couchdb/branches/1.1.x/src/couchdb/couch_view.erl?rev=1152406&r1=1152405&r2=1152406&view=diff
==============================================================================
--- couchdb/branches/1.1.x/src/couchdb/couch_view.erl (original)
+++ couchdb/branches/1.1.x/src/couchdb/couch_view.erl Sat Jul 30 00:37:32 2011
@@ -252,8 +252,16 @@ fold_fun(Fun, [KV|Rest], {KVReds, Reds},
 
 fold(#view{btree=Btree}, Fun, Acc, Options) ->
     WrapperFun =
-        fun(KV, Reds, Acc2) ->
-            fold_fun(Fun, expand_dups([KV],[]), Reds, Acc2)
+        fun(visit, KV, Reds, Acc2) ->
+            fold_fun(Fun, expand_dups([KV],[]), Reds, Acc2);
+           (traverse, LK, Red, Acc2)
+              when is_function(Fun, 4) ->
+                Fun(traverse, LK, Red, Acc2);
+           (traverse, _LK, Red, {_, Skip, _, _} = Acc2)
+              when Skip >= element(1, Red) ->
+                {skip, setelement(2, Acc2, Skip - element(1, Red))};
+           (traverse, _, _, Acc2) ->
+                {ok, Acc2}
         end,
     {ok, _LastReduce, _AccResult} = couch_btree:fold(Btree, WrapperFun, Acc, Options).
 



Mime
View raw message