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/09/02 19:06:35 UTC

svn commit: r691322 - in /incubator/couchdb/trunk: share/www/script/couch_tests.js src/couchdb/couch_db_updater.erl

Author: damien
Date: Tue Sep  2 10:06:33 2008
New Revision: 691322

URL: http://svn.apache.org/viewvc?rev=691322&view=rev
Log:
Fix for bug COUCHDB-109.

Modified:
    incubator/couchdb/trunk/share/www/script/couch_tests.js
    incubator/couchdb/trunk/src/couchdb/couch_db_updater.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=691322&r1=691321&r2=691322&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 Sep  2 10:06:33 2008
@@ -56,9 +56,15 @@
     var results = db.allDocs();
     var rows = results.rows;
 
+    T(results.total_rows == results.rows.length);
+
     for(var i=0; i < rows.length; i++) {
       T(rows[i].id >= "0" && rows[i].id <= "4");
     }
+    
+    // Check _all_docs with descending=true
+    var desc = db.allDocs({descending:true});
+    T(desc.total_rows == desc.rows.length);
 
     // Test a simple map functions
 

Modified: incubator/couchdb/trunk/src/couchdb/couch_db_updater.erl
URL: http://svn.apache.org/viewvc/incubator/couchdb/trunk/src/couchdb/couch_db_updater.erl?rev=691322&r1=691321&r2=691322&view=diff
==============================================================================
--- incubator/couchdb/trunk/src/couchdb/couch_db_updater.erl (original)
+++ incubator/couchdb/trunk/src/couchdb/couch_db_updater.erl Tue Sep  2 10:06:33 2008
@@ -147,13 +147,13 @@
 
 
 btree_by_id_reduce(reduce, FullDocInfos) ->
-    % count the number of deleted documents
+    % count the number of not deleted documents
     length([1 || #full_doc_info{deleted=false} <- FullDocInfos]);
 btree_by_id_reduce(rereduce, Reds) ->
     lists:sum(Reds).
             
 btree_by_seq_reduce(reduce, DocInfos) ->
-    % count the number of deleted documents
+    % count the number of documents
     length(DocInfos);
 btree_by_seq_reduce(rereduce, Reds) ->
     lists:sum(Reds).
@@ -161,10 +161,18 @@
 init_db(DbName, Filepath, Fd, Header) ->
     {ok, SummaryStream} = couch_stream:open(Header#db_header.summary_stream_state, Fd),
     ok = couch_stream:set_min_buffer(SummaryStream, 10000),
+    Less =
+        fun(A,B) when A==B -> false;
+        (nil, _) -> true; % nil - special key sorts before all
+        ({}, _) -> false; % {} -> special key sorts after all
+        (A, B) -> A < B
+        end,
+            
     {ok, IdBtree} = couch_btree:open(Header#db_header.fulldocinfo_by_id_btree_state, Fd,
         [{split, fun(X) -> btree_by_id_split(X) end},
         {join, fun(X,Y) -> btree_by_id_join(X,Y) end},
-        {reduce, fun(X,Y) -> btree_by_id_reduce(X,Y) end}]),
+        {reduce, fun(X,Y) -> btree_by_id_reduce(X,Y) end},
+        {less, Less}]),
     {ok, SeqBtree} = couch_btree:open(Header#db_header.docinfo_by_seq_btree_state, Fd,
             [{split, fun(X) -> btree_by_seq_split(X) end},
             {join, fun(X,Y) -> btree_by_seq_join(X,Y) end},