You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by da...@apache.org on 2008/10/21 20:43:44 UTC

svn commit: r706714 - in /incubator/couchdb/trunk: share/www/script/couch_tests.js src/couchdb/couch_btree.erl src/couchdb/couch_httpd_view.erl

Author: damien
Date: Tue Oct 21 11:43:42 2008
New Revision: 706714

URL: http://svn.apache.org/viewvc?rev=706714&view=rev
Log:
Fix for COUCHDB-99. Certain Skipped KeyValue pairs weren't being assembled into final values before being reduces.

Modified:
    incubator/couchdb/trunk/share/www/script/couch_tests.js
    incubator/couchdb/trunk/src/couchdb/couch_btree.erl
    incubator/couchdb/trunk/src/couchdb/couch_httpd_view.erl

Modified: incubator/couchdb/trunk/share/www/script/couch_tests.js
URL: http://svn.apache.org/viewvc/incubator/couchdb/trunk/share/www/script/couch_tests.js?rev=706714&r1=706713&r2=706714&view=diff
==============================================================================
--- incubator/couchdb/trunk/share/www/script/couch_tests.js [utf-8] (original)
+++ incubator/couchdb/trunk/share/www/script/couch_tests.js [utf-8] Tue Oct 21 11:43:42 2008
@@ -72,6 +72,10 @@
     // Check _all_docs with descending=true
     var desc = db.allDocs({descending:true});
     T(desc.total_rows == desc.rows.length);
+ 
+    // Check _all_docs offset
+    var all = db.allDocs({startkey:"2"});
+    T(all.offset == 2);
 
     // Test a simple map functions
 

Modified: incubator/couchdb/trunk/src/couchdb/couch_btree.erl
URL: http://svn.apache.org/viewvc/incubator/couchdb/trunk/src/couchdb/couch_btree.erl?rev=706714&r1=706713&r2=706714&view=diff
==============================================================================
--- incubator/couchdb/trunk/src/couchdb/couch_btree.erl (original)
+++ incubator/couchdb/trunk/src/couchdb/couch_btree.erl Tue Oct 21 11:43:42 2008
@@ -637,7 +637,8 @@
         fun({Key, _}) -> less(Bt, StartKey, Key) end
     end,
     {LTKVs, GTEKVs} = lists:splitwith(DropFun, KVs),
-    stream_kv_node2(Bt, Reds, LTKVs, GTEKVs, Dir, Fun, Acc).
+    AssembleLTKVs = [assemble(Bt,K,V) || {K,V} <- LTKVs],
+    stream_kv_node2(Bt, Reds, AssembleLTKVs, GTEKVs, Dir, Fun, Acc).
 
 stream_kv_node2(_Bt, _Reds, _PrevKVs, [], _Dir, _Fun, Acc) ->
     {ok, Acc};

Modified: incubator/couchdb/trunk/src/couchdb/couch_httpd_view.erl
URL: http://svn.apache.org/viewvc/incubator/couchdb/trunk/src/couchdb/couch_httpd_view.erl?rev=706714&r1=706713&r2=706714&view=diff
==============================================================================
--- incubator/couchdb/trunk/src/couchdb/couch_httpd_view.erl (original)
+++ incubator/couchdb/trunk/src/couchdb/couch_httpd_view.erl Tue Oct 21 11:43:42 2008
@@ -370,7 +370,6 @@
 
     fun({{Key, DocId}, Value}, OffsetReds,
                       {AccCount, AccSkip, Resp, AccRevRows}) ->
-        Offset = ReduceCountFun(OffsetReds), % I think we only need this call once per view
         PassedEnd = PassedEndFun(Key, DocId),
         case {PassedEnd, AccCount, AccSkip, Resp} of
         {true, _, _, _} ->
@@ -383,6 +382,8 @@
             {ok, {AccCount, AccSkip - 1, Resp, AccRevRows}};
         {_, _, _, undefined} ->
             {ok, Resp2} = start_json_response(Req, 200),
+            io:format("OffsetReds:~p~n", [OffsetReds]),
+            Offset = ReduceCountFun(OffsetReds),
             JsonBegin = io_lib:format("{\"total_rows\":~w,\"offset\":~w,\"rows\":[\r\n",
                     [TotalViewCount, Offset]),
             JsonObj = view_row_obj(Db, {{Key, DocId}, Value}, IncludeDocs),