summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDamien F. Katz <damien@apache.org>2008-09-02 17:06:33 +0000
committerDamien F. Katz <damien@apache.org>2008-09-02 17:06:33 +0000
commita75a39b2a47f3275f198cffa932a78bd70e1cac4 (patch)
tree8ef357812f2f6285c0b354003a4511ea232eac3b /src
parent36445192cd67e6a01233eb8cd7179b2afbc72947 (diff)
Fix for bug COUCHDB-109.
git-svn-id: https://svn.apache.org/repos/asf/incubator/couchdb/trunk@691322 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src')
-rw-r--r--src/couchdb/couch_db_updater.erl14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/couchdb/couch_db_updater.erl b/src/couchdb/couch_db_updater.erl
index befbfed2..cc916961 100644
--- a/src/couchdb/couch_db_updater.erl
+++ b/src/couchdb/couch_db_updater.erl
@@ -147,13 +147,13 @@ btree_by_id_join(Id, {Seq, Deleted, Tree}) ->
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 @@ btree_by_seq_reduce(rereduce, Reds) ->
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},