[JAVA-5080] Add chained wrappers for aggregation stages Created: 17/Jul/23 Updated: 03/Oct/23 |
|
| Status: | Backlog |
| Project: | Java Driver |
| Component/s: | Builders |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | New Feature | Priority: | Unknown |
| Reporter: | Maxim Katcharov | Assignee: | Unassigned |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||
| Quarter: | FY25Q1 | ||||||||
| Documentation Changes Summary: | 1. What would you like to communicate to the user about this feature? |
||||||||
| Description |
|
In Creating chained implementations of the aggregation stages would a) make the API as a whole more consistent, b) remove the need for "glue" like `current()`, and c) would allow users to take advantage of the "debug" API for development. The negative effect is that this would introduce a second API, which we would need to commit to. An example of the API:
This performs an aggregation on a collection of diagrams, with shapes. It adds a field to the diagram, filters on that field, and then counts the results. I used a "toList" method in the POC for convenience. The "debug" method enables stage-level debugging, via $documents, of the aggregation chain. The "stage" method accepts the existing BSON stages. For example, "addField" is implemented as:
This removes the need for "current()", since in the example, current is "d", just as each shape item under "map" is represented as "shape". The above example also uses schema classes (JAVA-5081) to save on "getField" calls.
|