couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fdman...@apache.org
Subject svn commit: r1097594 - /couchdb/trunk/src/couchdb/couch_db.erl
Date Thu, 28 Apr 2011 20:12:59 GMT
Author: fdmanana
Date: Thu Apr 28 20:12:58 2011
New Revision: 1097594

URL: http://svn.apache.org/viewvc?rev=1097594&view=rev
Log:
Include local docs btree size in the database data_size field computation

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

Modified: couchdb/trunk/src/couchdb/couch_db.erl
URL: http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/couch_db.erl?rev=1097594&r1=1097593&r2=1097594&view=diff
==============================================================================
--- couchdb/trunk/src/couchdb/couch_db.erl (original)
+++ couchdb/trunk/src/couchdb/couch_db.erl Thu Apr 28 20:12:58 2011
@@ -254,7 +254,8 @@ get_db_info(Db) ->
         instance_start_time=StartTime,
         committed_update_seq=CommittedUpdateSeq,
         fulldocinfo_by_id_btree = IdBtree,
-        docinfo_by_seq_btree = SeqBtree
+        docinfo_by_seq_btree = SeqBtree,
+        local_docs_btree = LocalBtree
     } = Db,
     {ok, Size} = couch_file:bytes(Fd),
     {ok, DbReduction} = couch_btree:full_reduce(by_id_btree(Db)),
@@ -266,25 +267,30 @@ get_db_info(Db) ->
         {purge_seq, couch_db:get_purge_seq(Db)},
         {compact_running, Compactor/=nil},
         {disk_size, Size},
-        {data_size, db_data_size(
-            couch_btree:size(SeqBtree), couch_btree:size(IdBtree), DbReduction)},
+        {data_size, db_data_size(DbReduction, [SeqBtree, IdBtree, LocalBtree])},
         {instance_start_time, StartTime},
         {disk_format_version, DiskVersion},
         {committed_update_seq, CommittedUpdateSeq}
         ],
     {ok, InfoList}.
 
-db_data_size(nil, _, _) ->
-    null;
-db_data_size(_, nil, _) ->
-    null;
-db_data_size(_, _, {_Count, _DelCount}) ->
+db_data_size({_Count, _DelCount}, _Trees) ->
     % pre 1.2 format, upgraded on compaction
     null;
-db_data_size(_, _, {_Count, _DelCount, nil}) ->
+db_data_size({_Count, _DelCount, nil}, _Trees) ->
     null;
-db_data_size(SeqBtreeSize, IdBtreeSize, {_Count, _DelCount, DocAndAttsSize}) ->
-    SeqBtreeSize + IdBtreeSize + DocAndAttsSize.
+db_data_size({_Count, _DelCount, DocAndAttsSize}, Trees) ->
+    sum_tree_sizes(DocAndAttsSize, Trees).
+
+sum_tree_sizes(Acc, []) ->
+    Acc;
+sum_tree_sizes(Acc, [T | Rest]) ->
+    case couch_btree:size(T) of
+    nil ->
+        null;
+    Sz ->
+        sum_tree_sizes(Acc + Sz, Rest)
+    end.
 
 get_design_docs(Db) ->
     {ok,_, Docs} = couch_btree:fold(by_id_btree(Db),



Mime
View raw message