-
Type: Task
-
Resolution: Duplicate
-
Priority: Major - P3
-
None
-
Affects Version/s: None
-
Component/s: None
-
None
-
Query Integration
As of now, the the runAggregate() function takes in the AggregateCommandRequest and its associated parsed structures (LiteParsedPipeline & BSONObj) by lvalue reference.
This pattern makes sense as these objects are created and referenced in the calling context, and we want to take them by reference because we don't want to copy or rebuild them in the runAggregate() context. However, we should go a step further and actually pass in these objects by rvalue so they can be move assigned internally in runAggregate(). This way its clear in the both the calling and runAggregate() context that runAggregate() now has full ownership of these objects and can manipulate them internally as needed. We do actually need to reassign these objects in the case of running an aggregate on a resolved view, which would be possible after these objects are owned internally.
Also after the move assignment is complete, we should edit AggExState::AggregateCommandRequest to keep its internal objects by value, instead of by reference, so that _aggRequestDerivatives can be reassigned and not be wrapped in a pointer.