davisp commented on a change in pull request #608: Calculate ExternalSize
Correctly for Views
URL: https://github.com/apache/couchdb/pull/608#discussion_r123804583
##########
File path: src/couch_mrview/src/couch_mrview_util.erl
##########
@@ -786,26 +788,32 @@ changes_ekey_opts(_StartSeq, #mrargs{end_key=EKey,
end.
+reduced_external_size(Tree) ->
+ case couch_btree:full_reduce(Tree) of
+ {ok, {_, _, Size}} -> Size;
+ % return null for versions of the reduce function without Size
+ {ok, {_, _}} -> null
+ end.
calculate_external_size(Views) ->
SumFun = fun(#mrview{btree=Bt, seq_btree=SBt, key_byseq_btree=KSBt}, Acc)
->
- Size0 = sum_btree_sizes(Acc, couch_btree:size(Bt)),
+ Size0 = sum_btree_sizes(Acc, reduced_external_size(Bt)),
Size1 = case SBt of
nil -> Size0;
- _ -> sum_btree_sizes(Size0, couch_btree:size(SBt))
+ _ -> sum_btree_sizes(Size0, reduced_external_size(SBt))
end,
case KSBt of
nil -> Size1;
- _ -> sum_btree_sizes(Size1, couch_btree:size(KSBt))
+ _ -> sum_btree_sizes(Size1, reduced_external_size(KSBt))
end
end,
{ok, lists:foldl(SumFun, 0, Views)}.
-sum_btree_sizes(nil, _) ->
+sum_btree_sizes(null, _) ->
Review comment:
This nil/null change strikes me as possibly problematic for the non KV trees.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services