couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rand...@apache.org
Subject svn commit: r1152398 - in /couchdb/trunk/src/couchdb: couch_db.erl couch_view.erl
Date Sat, 30 Jul 2011 00:04:26 GMT
Author: randall
Date: Sat Jul 30 00:04:26 2011
New Revision: 1152398

URL: http://svn.apache.org/viewvc?rev=1152398&view=rev
Log:
Fix COUCHDB-1076 - views skip empty btree branches

Modified:
    couchdb/trunk/src/couchdb/couch_db.erl
    couchdb/trunk/src/couchdb/couch_view.erl

Modified: couchdb/trunk/src/couchdb/couch_db.erl
URL: http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/couch_db.erl?rev=1152398&r1=1152397&r2=1152398&view=diff
==============================================================================
--- couchdb/trunk/src/couchdb/couch_db.erl (original)
+++ couchdb/trunk/src/couchdb/couch_db.erl Sat Jul 30 00:04:26 2011
@@ -295,7 +295,8 @@ sum_tree_sizes(Acc, [T | Rest]) ->
     end.
 
 get_design_docs(Db) ->
-    {ok,_, Docs} = couch_btree:fold(by_id_btree(Db),
+    {ok, _, Docs} = couch_view:fold(
+        #view{btree=by_id_btree(Db)},
         fun(#full_doc_info{id= <<"_design/",_/binary>>}=FullDocInfo, _Reds, AccDocs)
->
             {ok, Doc} = open_doc_int(Db, FullDocInfo, [ejson_body]),
             {ok, [Doc | AccDocs]};
@@ -1055,8 +1056,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(
-        by_id_btree(Db), InFun, InAcc, Options),
+    {ok, LastReduce, OutAcc} = couch_view:fold(
+        #view{btree=by_id_btree(Db)}, InFun, InAcc, Options),
     {ok, enum_docs_reduce_to_count(LastReduce), OutAcc}.
 
 % server functions

Modified: couchdb/trunk/src/couchdb/couch_view.erl
URL: http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/couch_view.erl?rev=1152398&r1=1152397&r2=1152398&view=diff
==============================================================================
--- couchdb/trunk/src/couchdb/couch_view.erl (original)
+++ couchdb/trunk/src/couchdb/couch_view.erl Sat Jul 30 00:04:26 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