couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rnew...@apache.org
Subject couch-mrview commit: updated refs/heads/windsor-merge to db88586
Date Fri, 22 Aug 2014 15:57:08 GMT
Repository: couchdb-couch-mrview
Updated Branches:
  refs/heads/windsor-merge 2c41c9d31 -> db8858643


Merge data_size calculations for views

This adds the new data size information to view info data.

BugzId: 27061


Project: http://git-wip-us.apache.org/repos/asf/couchdb-couch-mrview/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-couch-mrview/commit/db885864
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-couch-mrview/tree/db885864
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-couch-mrview/diff/db885864

Branch: refs/heads/windsor-merge
Commit: db88586439f0e1f5c35203d5d9d98aa9a5a47c2c
Parents: 2c41c9d
Author: Robert Newson <rnewson@apache.org>
Authored: Fri Aug 22 16:56:44 2014 +0100
Committer: Robert Newson <rnewson@apache.org>
Committed: Fri Aug 22 16:56:44 2014 +0100

----------------------------------------------------------------------
 src/couch_mrview_index.erl | 14 ++++++++++----
 src/couch_mrview_util.erl  |  6 +++---
 2 files changed, 13 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-couch-mrview/blob/db885864/src/couch_mrview_index.erl
----------------------------------------------------------------------
diff --git a/src/couch_mrview_index.erl b/src/couch_mrview_index.erl
index 709a6a9..ab30b7d 100644
--- a/src/couch_mrview_index.erl
+++ b/src/couch_mrview_index.erl
@@ -57,13 +57,19 @@ get(Property, State) ->
                 purge_seq = PurgeSeq,
                 views = Views
             } = State,
-            {ok, Size} = couch_file:bytes(Fd),
-            {ok, DataSize} = couch_mrview_util:calculate_data_size(Btree,Views),
+            {ok, FileSize} = couch_file:bytes(Fd),
+            {ok, ExternalSize} = couch_mrview_util:calculate_external_size(Views),
+            ActiveSize = ExternalSize + couch_btree:size(Btree),
             {ok, [
                 {signature, list_to_binary(couch_index_util:hexsig(Sig))},
                 {language, Lang},
-                {disk_size, Size},
-                {data_size, DataSize},
+                {disk_size, FileSize}, % legacy
+                {data_size, ExternalSize}, % legacy
+                {sizes, {[
+                    {file, FileSize},
+                    {active, ActiveSize},
+                    {external, ExternalSize}
+                ]}},
                 {update_seq, UpdateSeq},
                 {purge_seq, PurgeSeq}
             ]};

http://git-wip-us.apache.org/repos/asf/couchdb-couch-mrview/blob/db885864/src/couch_mrview_util.erl
----------------------------------------------------------------------
diff --git a/src/couch_mrview_util.erl b/src/couch_mrview_util.erl
index cbba5ac..1836338 100644
--- a/src/couch_mrview_util.erl
+++ b/src/couch_mrview_util.erl
@@ -21,7 +21,7 @@
 -export([all_docs_key_opts/1, all_docs_key_opts/2, key_opts/1, key_opts/2]).
 -export([fold/4, fold_reduce/4]).
 -export([temp_view_to_ddoc/1]).
--export([calculate_data_size/2]).
+-export([calculate_external_size/1]).
 -export([validate_args/1]).
 -export([maybe_load_doc/3, maybe_load_doc/4]).
 -export([maybe_update_index_file/1]).
@@ -635,11 +635,11 @@ reverse_key_default(<<255>>) -> <<>>;
 reverse_key_default(Key) -> Key.
 
 
-calculate_data_size(IdBt, Views) ->
+calculate_external_size(Views) ->
     SumFun = fun(#mrview{btree=Bt}, Acc) ->
         sum_btree_sizes(Acc, couch_btree:size(Bt))
     end,
-    Size = lists:foldl(SumFun, couch_btree:size(IdBt), Views),
+    Size = lists:foldl(SumFun, 0, Views),
     {ok, Size}.
 
 


Mime
View raw message