diff options
author | Ian Boros <ian.boros@mongodb.com> | 2020-01-30 13:10:55 -0500 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2020-02-28 22:16:41 +0000 |
commit | cfa5c05fa1855fb1a04cb3a6e2eb10a7e82bf726 (patch) | |
tree | 7ab1e1ce8e2edd6837952c131fe14d43a0633235 /src/mongo/db/exec/subplan.cpp | |
parent | 793ae32c597f197b6445750aa9bfdaabc206132d (diff) | |
download | mongo-cfa5c05fa1855fb1a04cb3a6e2eb10a7e82bf726.tar.gz |
SERVER-45406 Plumb ExpressionContext through PlanStage
This patch includes also moves ownership of the collator to the ExpressionContext.
Diffstat (limited to 'src/mongo/db/exec/subplan.cpp')
-rw-r--r-- | src/mongo/db/exec/subplan.cpp | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/src/mongo/db/exec/subplan.cpp b/src/mongo/db/exec/subplan.cpp index 32c4cfa0bb8..054f48e3a2b 100644 --- a/src/mongo/db/exec/subplan.cpp +++ b/src/mongo/db/exec/subplan.cpp @@ -59,12 +59,12 @@ using std::vector; const char* SubplanStage::kStageType = "SUBPLAN"; -SubplanStage::SubplanStage(OperationContext* opCtx, +SubplanStage::SubplanStage(ExpressionContext* expCtx, const Collection* collection, WorkingSet* ws, const QueryPlannerParams& params, CanonicalQuery* cq) - : RequiresAllIndicesStage(kStageType, opCtx, collection), + : RequiresAllIndicesStage(kStageType, expCtx, collection), _ws(ws), _plannerParams(params), _query(cq) { @@ -122,7 +122,7 @@ Status SubplanStage::planSubqueries() { MatchExpression* orChild = _orExpression->getChild(i); // Turn the i-th child into its own query. - auto statusWithCQ = CanonicalQuery::canonicalize(getOpCtx(), *_query, orChild); + auto statusWithCQ = CanonicalQuery::canonicalize(opCtx(), *_query, orChild); if (!statusWithCQ.isOK()) { str::stream ss; ss << "Can't canonicalize subchild " << orChild->debugString() << " " @@ -263,7 +263,7 @@ Status SubplanStage::choosePlanForSubqueries(PlanYieldPolicy* yieldPolicy) { // messages that can be generated if pickBestPlan yields. invariant(_children.empty()); _children.emplace_back( - std::make_unique<MultiPlanStage>(getOpCtx(), + std::make_unique<MultiPlanStage>(expCtx(), collection(), branchResult->canonicalQuery.get(), MultiPlanStage::CachingMode::SometimesCache)); @@ -275,7 +275,7 @@ Status SubplanStage::choosePlanForSubqueries(PlanYieldPolicy* yieldPolicy) { // Dump all the solutions into the MPS. for (size_t ix = 0; ix < branchResult->solutions.size(); ++ix) { - auto nextPlanRoot = StageBuilder::build(getOpCtx(), + auto nextPlanRoot = StageBuilder::build(opCtx(), collection(), *branchResult->canonicalQuery, *branchResult->solutions[ix], @@ -362,8 +362,7 @@ Status SubplanStage::choosePlanForSubqueries(PlanYieldPolicy* yieldPolicy) { // Use the index tags from planning each branch to construct the composite solution, // and set that solution as our child stage. _ws->clear(); - auto root = - StageBuilder::build(getOpCtx(), collection(), *_query, *_compositeSolution.get(), _ws); + auto root = StageBuilder::build(opCtx(), collection(), *_query, *_compositeSolution.get(), _ws); invariant(_children.empty()); _children.emplace_back(std::move(root)); @@ -385,7 +384,7 @@ Status SubplanStage::choosePlanWholeQuery(PlanYieldPolicy* yieldPolicy) { if (1 == solutions.size()) { // Only one possible plan. Run it. Build the stages from the solution. - auto root = StageBuilder::build(getOpCtx(), collection(), *_query, *solutions[0], _ws); + auto root = StageBuilder::build(opCtx(), collection(), *_query, *solutions[0], _ws); invariant(_children.empty()); _children.emplace_back(std::move(root)); @@ -398,7 +397,7 @@ Status SubplanStage::choosePlanWholeQuery(PlanYieldPolicy* yieldPolicy) { // Many solutions. Create a MultiPlanStage to pick the best, update the cache, // and so on. The working set will be shared by all candidate plans. invariant(_children.empty()); - _children.emplace_back(new MultiPlanStage(getOpCtx(), collection(), _query)); + _children.emplace_back(new MultiPlanStage(expCtx(), collection(), _query)); MultiPlanStage* multiPlanStage = static_cast<MultiPlanStage*>(child().get()); for (size_t ix = 0; ix < solutions.size(); ++ix) { @@ -407,7 +406,7 @@ Status SubplanStage::choosePlanWholeQuery(PlanYieldPolicy* yieldPolicy) { } auto nextPlanRoot = - StageBuilder::build(getOpCtx(), collection(), *_query, *solutions[ix], _ws); + StageBuilder::build(opCtx(), collection(), *_query, *solutions[ix], _ws); multiPlanStage->addPlan(std::move(solutions[ix]), std::move(nextPlanRoot), _ws); } |