You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by va...@apache.org on 2019/03/28 21:30:01 UTC

[couchdb] branch reshard updated: [fixup|couch_db_split] fix external size calculation

This is an automated email from the ASF dual-hosted git repository.

vatamane pushed a commit to branch reshard
in repository https://gitbox.apache.org/repos/asf/couchdb.git


The following commit(s) were added to refs/heads/reshard by this push:
     new cfb0cfc  [fixup|couch_db_split] fix external size calculation
cfb0cfc is described below

commit cfb0cfc6c94a5455a3c42eef503b7a68c0eea160
Author: Nick Vatamaniuc <va...@apache.org>
AuthorDate: Thu Mar 28 17:29:34 2019 -0400

    [fixup|couch_db_split] fix external size calculation
---
 src/couch/src/couch_db_split.erl | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/src/couch/src/couch_db_split.erl b/src/couch/src/couch_db_split.erl
index ac757ac..b9c23a9 100644
--- a/src/couch/src/couch_db_split.erl
+++ b/src/couch/src/couch_db_split.erl
@@ -374,7 +374,7 @@ revtree_cb(_Rev, _Leaf, branch, Acc) ->
 
 revtree_cb({Pos, RevId}, Leaf, leaf, Acc) ->
     #racc{id = Id, source_db = SourceDb, target_db = TargetDb} = Acc,
-    #leaf{deleted = Deleted, ptr = Ptr} = Leaf,
+    #leaf{deleted = Deleted, ptr = Ptr, sizes = LeafSizes} = Leaf,
     Doc0 = #doc{
         id = Id,
         revs = {Pos, [RevId]},
@@ -383,8 +383,12 @@ revtree_cb({Pos, RevId}, Leaf, leaf, Acc) ->
     },
     Doc1 = couch_db_engine:read_doc_body(SourceDb, Doc0),
     #doc{body = Body, atts = AttInfos0} = Doc1,
-    External = if not is_binary(Body) -> ?term_size(body); true ->
-        couch_compress:uncompressed_size(Body)
+    External = case LeafSizes#size_info.external of
+        0 when is_binary(Body) ->
+            couch_compress:uncompressed_size(Body);
+        0 ->
+            couch_ejson_size:encoded_size(Body);
+        N -> N
     end,
     AttInfos = if not is_binary(AttInfos0) -> AttInfos0; true ->
         couch_compress:decompress(AttInfos0)