You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by to...@apache.org on 2017/07/11 23:56:41 UTC

[couchdb] 01/02: use 0 as return value for no external size value

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

tonysun83 pushed a commit to branch 3430-external-size-views
in repository https://gitbox.apache.org/repos/asf/couchdb.git

commit ab6db5f98d15e4428b012236ca5c0344b4040fc9
Author: Tony Sun <to...@cloudant.com>
AuthorDate: Wed Jun 28 19:10:07 2017 -0700

    use 0 as return value for no external size value
    
    COUCHDB-3430
---
 src/couch_mrview/src/couch_mrview_util.erl | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/src/couch_mrview/src/couch_mrview_util.erl b/src/couch_mrview/src/couch_mrview_util.erl
index f09f4eb..aae08ae 100644
--- a/src/couch_mrview/src/couch_mrview_util.erl
+++ b/src/couch_mrview/src/couch_mrview_util.erl
@@ -612,6 +612,7 @@ make_header(State) ->
         log_btree=LogBtree,
         views=Views
     } = State,
+
     #mrheader{
         seq=Seq,
         purge_seq=PurgeSeq,
@@ -791,8 +792,8 @@ changes_ekey_opts(_StartSeq, #mrargs{end_key=EKey,
 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
+        % return 0 for versions of the reduce function without Size
+        {ok, {_, _}} -> 0
     end.
 
 
@@ -811,10 +812,10 @@ calculate_external_size(Views) ->
     {ok, lists:foldl(SumFun, 0, Views)}.
 
 
-sum_btree_sizes(null, _) ->
-    null;
-sum_btree_sizes(_, null) ->
-    null;
+sum_btree_sizes(nil, _) ->
+    0;
+sum_btree_sizes(_, nil) ->
+    0;
 sum_btree_sizes(Size1, Size2) ->
     Size1 + Size2.
 
@@ -1152,5 +1153,5 @@ get_view_queries({Props}) ->
 
 kv_external_size(KVList, Reduction) ->
     lists:foldl(fun([[Key, _], Value], Acc) ->
-        size(term_to_binary(Key)) + size(term_to_binary(Value)) + Acc
-    end, size(term_to_binary(Reduction)), KVList).
+        ?term_size(Key) + ?term_size(Value) + Acc
+    end, ?term_size(Reduction), KVList).

-- 
To stop receiving notification emails like this one, please contact
"commits@couchdb.apache.org" <co...@couchdb.apache.org>.