|
IIUC, the support for merge in $group pushdown is all about how each accumulator merges partial aggregation results from multiple shards at the mongo*S*-side and how each accumulator produces partial aggregation results at the shard-side.
One quite interesting aspect is that for example, $avg, we may need the finalization step and a different accumulation step at the mongo*S*-side, and we need accumulation steps and the finalization steps for both $sum and $count but not the normal $avg finalization step at the shard-side.
Another interesting question is would we return the fully-materialized BSON object for the partial aggregation results or just return the partial aggregation results as a mixed-type array and we find relevant elements by their positions to save some (de)serialization overhead and network bandwidth. For example, $avg, we may want to return [partial_sum, partial_count] instead of {āsā: partial_sum, ācā: partial_count} for partial $avg results.
|