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/08/05 18:22:12 UTC
[couchdb] 04/04: Improve GroupKey notification
This is an automated email from the ASF dual-hosted git repository.
davisp pushed a commit to branch ebtree-fixes
in repository https://gitbox.apache.org/repos/asf/couchdb.git
commit 3fb53ec57d0a2345b89fae8237571627277b9909
Author: Paul J. Davis <pa...@gmail.com>
AuthorDate: Wed Aug 5 13:21:01 2020 -0500
Improve GroupKey notification
The default `<<0:1>>` NoGroupSet being passed to reduce functions is a
bit awkward.
---
src/ebtree/src/ebtree.erl | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/src/ebtree/src/ebtree.erl b/src/ebtree/src/ebtree.erl
index 5051d94..1cbc507 100644
--- a/src/ebtree/src/ebtree.erl
+++ b/src/ebtree/src/ebtree.erl
@@ -392,8 +392,12 @@ group_reduce(Db, #tree{} = Tree, StartKey, EndKey, GroupKeyFun, UserAccFun, User
{CurrentGroup, UserAcc1, MapValues, ReduceValues} = fold(Db, Tree, Fun, {NoGroupYet, UserAcc0, [], []}, Options),
if
MapValues /= [] orelse ReduceValues /= [] ->
- FinalGroup = do_reduce(Tree, MapValues, ReduceValues),
- UserAccFun({CurrentGroup, FinalGroup}, UserAcc1);
+ FinalGroupKey = case CurrentGroup of
+ NoGroupYet -> undefined;
+ _ -> CurrentGroup
+ end,
+ FinalReduction = do_reduce(Tree, MapValues, ReduceValues),
+ UserAccFun({FinalGroupKey, FinalReduction}, UserAcc1);
true ->
UserAcc1
end.