You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by da...@apache.org on 2020/10/21 19:53:13 UTC

[couchdb] branch fix-empty-reduce-output updated (04736c0 -> 9e91891)

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

davisp pushed a change to branch fix-empty-reduce-output
in repository https://gitbox.apache.org/repos/asf/couchdb.git.


 discard 04736c0  Remove debug logging
 discard 4d28a6e  Fix empty reduce output to match 3.x behavior
     new 69f1c60  Fix empty reduce output to match 3.x behavior
     new 9e91891  Remove debug logging

This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version.  This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:

 * -- * -- B -- O -- O -- O   (04736c0)
            \
             N -- N -- N   refs/heads/fix-empty-reduce-output (9e91891)

You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.

Any revisions marked "omit" are not gone; other references still
refer to them.  Any revisions marked "discard" are gone forever.

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 src/couch_views/test/couch_views_red_test.erl | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)


[couchdb] 02/02: Remove debug logging

Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

davisp pushed a commit to branch fix-empty-reduce-output
in repository https://gitbox.apache.org/repos/asf/couchdb.git

commit 9e918919a40265f2790946f37df453df4ba01d32
Author: Paul J. Davis <pa...@gmail.com>
AuthorDate: Wed Oct 21 14:44:47 2020 -0500

    Remove debug logging
---
 src/couch_views/src/couch_views_trees.erl | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/src/couch_views/src/couch_views_trees.erl b/src/couch_views/src/couch_views_trees.erl
index 6c32f97..ad3660e 100644
--- a/src/couch_views/src/couch_views_trees.erl
+++ b/src/couch_views/src/couch_views_trees.erl
@@ -279,9 +279,6 @@ min_order(V) ->
 
 make_read_only_reduce_fun(Lang, View, NthRed) ->
     RedFuns = [Src || {_, Src} <- View#mrview.reduce_funs],
-    if RedFuns /= [] -> ok; true ->
-        io:format(standard_error, "~p~n", [process_info(self(), current_stacktrace)])
-    end,
     LPad = lists:duplicate(NthRed - 1, []),
     RPad = lists:duplicate(length(RedFuns) - NthRed, []),
     FunSrc = lists:nth(NthRed, RedFuns),


[couchdb] 01/02: Fix empty reduce output to match 3.x behavior

Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

davisp pushed a commit to branch fix-empty-reduce-output
in repository https://gitbox.apache.org/repos/asf/couchdb.git

commit 69f1c6076fd29a7ef925dbeeb7fef2527ad8b68d
Author: Paul J. Davis <pa...@gmail.com>
AuthorDate: Wed Oct 21 14:42:43 2020 -0500

    Fix empty reduce output to match 3.x behavior
    
    Before this change a reduce call that contained no rows would end up
    returning the "default" value of the given reduce function which is
    whatever it would return when given an empty array as input. This
    changes the behavior to return `{"rows": []"}` when there are no
    rows in the requested range.
---
 src/couch_views/src/couch_views_trees.erl     | 25 +++++--------------------
 src/couch_views/test/couch_views_red_test.erl |  4 ++--
 2 files changed, 7 insertions(+), 22 deletions(-)

diff --git a/src/couch_views/src/couch_views_trees.erl b/src/couch_views/src/couch_views_trees.erl
index d9340ad..6c32f97 100644
--- a/src/couch_views/src/couch_views_trees.erl
+++ b/src/couch_views/src/couch_views_trees.erl
@@ -144,15 +144,8 @@ fold_red_idx(TxDb, View, Idx, Options, Callback, Acc0) ->
         Callback(GroupKey, RedValue, WAcc)
     end,
 
-    case {GroupKeyFun, Dir} of
-        {group_all, fwd} ->
-            EBtreeOpts = [
-                {dir, fwd},
-                {inclusive_end, InclusiveEnd}
-            ],
-            Reduction = ebtree:reduce(Tx, Btree, StartKey, EndKey, EBtreeOpts),
-            Wrapper({null, Reduction}, Acc0);
-        {F, fwd} when is_function(F) ->
+    case Dir of
+        fwd ->
             EBtreeOpts = [
                 {dir, fwd},
                 {inclusive_end, InclusiveEnd}
@@ -167,16 +160,7 @@ fold_red_idx(TxDb, View, Idx, Options, Callback, Acc0) ->
                     Acc0,
                     EBtreeOpts
                 );
-        {group_all, rev} ->
-            % Start/End keys swapped on purpose because ebtree. Also
-            % inclusive_start for same reason.
-            EBtreeOpts = [
-                {dir, rev},
-                {inclusive_start, InclusiveEnd}
-            ],
-            Reduction = ebtree:reduce(Tx, Btree, EndKey, StartKey, EBtreeOpts),
-            Wrapper({null, Reduction}, Acc0);
-        {F, rev} when is_function(F) ->
+        rev ->
             % Start/End keys swapped on purpose because ebtree. Also
             % inclusive_start for same reason.
             EBtreeOpts = [
@@ -404,8 +388,9 @@ to_red_opts(Options) ->
     {Dir, StartKey, EndKey, InclusiveEnd} = to_map_opts(Options),
 
     GroupKeyFun = case lists:keyfind(group_key_fun, 1, Options) of
+        {group_key_fun, group_all} -> fun({_Key, _DocId}) -> null end;
         {group_key_fun, GKF} -> GKF;
-        false -> fun({_Key, _DocId}) -> global_group end
+        false -> fun({_Key, _DocId}) -> null end
     end,
 
     {Dir, StartKey, EndKey, InclusiveEnd, GroupKeyFun}.
diff --git a/src/couch_views/test/couch_views_red_test.erl b/src/couch_views/test/couch_views_red_test.erl
index 707611f..84c6473 100644
--- a/src/couch_views/test/couch_views_red_test.erl
+++ b/src/couch_views/test/couch_views_red_test.erl
@@ -213,7 +213,7 @@ should_reduce_empty_range({Db, _}) ->
         end_key => 100001
     },
     Result = run_query(Db, <<"baz_count">>, Args),
-    Expect = {ok, [row(null, 0)]},
+    Expect = {ok, []},
     ?assertEqual(Expect, Result).
 
 
@@ -224,7 +224,7 @@ should_reduce_empty_range_rev({Db, _}) ->
         end_key => 100000
     },
     Result = run_query(Db, <<"baz_count">>, Args),
-    Expect = {ok, [row(null, 0)]},
+    Expect = {ok, []},
     ?assertEqual(Expect, Result).