tonysun83 commented on a change in pull request #608: Calculate ExternalSize
Correctly for Views
URL: https://github.com/apache/couchdb/pull/608#discussion_r124184415
##########
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:
@davisp: I changed ```reduced_external_size/1``` to return 0 for cases when
an ExternalSize is not returned. Previously, the value returned when there was
no ExternalSize was ```null```. So here I was accounting for the situation when
it was null. Now that I changed the value 0, it seems the only possible values
here are 0 or some other number. It can't be be nil or null?
----------------------------------------------------------------
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