Created
July 30, 2020 18:03
-
-
Save davisp/988b2dddb3c0b857860b7d164cf07eab to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| diff --git a/src/ebtree/src/ebtree.erl b/src/ebtree/src/ebtree.erl | |
| index 09704da83..ce1f48e0c 100644 | |
| --- a/src/ebtree/src/ebtree.erl | |
| +++ b/src/ebtree/src/ebtree.erl | |
| @@ -25,6 +25,7 @@ | |
| fold/4, | |
| fold/5, | |
| reduce/4, | |
| + reduce/5, | |
| full_reduce/2, | |
| group_reduce/7, | |
| group_reduce/8, | |
| @@ -413,12 +414,17 @@ group_reduce(Db, #tree{} = Tree, StartKey, EndKey, GroupKeyFun, UserAccFun, User | |
| end | |
| end, | |
| {CurrentGroup, UserAcc1, MapValues, ReduceValues} = fold(Db, Tree, Fun, {NoGroupYet, UserAcc0, [], []}, Options), | |
| - FinalGroupKey = case CurrentGroup of | |
| - NoGroupYet -> undefined; | |
| - _ -> CurrentGroup | |
| - end, | |
| - FinalGroupValue = do_reduce(Tree, MapValues, ReduceValues), | |
| - UserAccFun({FinalGroupKey, FinalGroupValue}, UserAcc1). | |
| + if | |
| + MapValues /= [] orelse ReduceValues /= [] -> | |
| + FinalGroupKey = case CurrentGroup of | |
| + NoGroupYet -> undefined; | |
| + _ -> CurrentGroup | |
| + end, | |
| + FinalReduction = do_reduce(Tree, MapValues, ReduceValues), | |
| + UserAccFun({FinalGroupKey, FinalReduction}, UserAcc1); | |
| + true -> | |
| + UserAcc1 | |
| + end. | |
| %% @doc Finds all key-value pairs for the specified range in forward order. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment