-
Type: Improvement
-
Resolution: Won't Fix
-
Priority: Major - P3
-
None
-
Affects Version/s: None
-
Component/s: None
-
None
-
Query Execution
-
45
$accumulator allows users to specify their own accumulator using JavaScript.
It has several functions. We will focus on this three:
init - created a new group (may use group id as arguments).
accumulate - adds a new document to the group.
merge - merges two groups (in case of sharding or spilling).
Currently our code assumes that we can call init() any number of times.
For example, consider group of two documents.
If there is no spilling, we will call the following functions:
init() -> accumulate() -> accumulate()
However, if we spill after each document, we will have the following sequence of calls:
init() -> accumulate() -> /spill/ -> init() -> accumulate() -> /spill/ -> init() -> merge() -> merge().
If init() doesn't return a neutral element in relation to accumulate() and merge(), we are in trouble.
In this ticket we should discuss how we want to handle this case: either assert init is correct and provide users with a comprehensive error message or re-design $accumulator to call init exactly once.
We also should note our decision in documentation to be more explicit.
- is depended on by
-
SERVER-77531 Make $accumulate resilient to spilling
- Closed