summaryrefslogtreecommitdiff
path: root/src/mongo/dbtests/query_stage_count.cpp
diff options
context:
space:
mode:
authorIan Boros <ian.boros@mongodb.com>2020-01-30 13:10:55 -0500
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2020-02-28 22:16:41 +0000
commitcfa5c05fa1855fb1a04cb3a6e2eb10a7e82bf726 (patch)
tree7ab1e1ce8e2edd6837952c131fe14d43a0633235 /src/mongo/dbtests/query_stage_count.cpp
parent793ae32c597f197b6445750aa9bfdaabc206132d (diff)
downloadmongo-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/dbtests/query_stage_count.cpp')
-rw-r--r--src/mongo/dbtests/query_stage_count.cpp16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/mongo/dbtests/query_stage_count.cpp b/src/mongo/dbtests/query_stage_count.cpp
index 0c62e6636f4..304297724be 100644
--- a/src/mongo/dbtests/query_stage_count.cpp
+++ b/src/mongo/dbtests/query_stage_count.cpp
@@ -60,6 +60,7 @@ public:
CountStageTest()
: _dbLock(&_opCtx, nsToDatabaseSubstring(ns()), MODE_X),
_ctx(&_opCtx, ns()),
+ _expCtx(make_intrusive<ExpressionContext>(&_opCtx, nullptr, kTestNss)),
_coll(nullptr) {}
virtual ~CountStageTest() {}
@@ -94,7 +95,8 @@ public:
params.direction = CollectionScanParams::FORWARD;
params.tailable = false;
- unique_ptr<CollectionScan> scan(new CollectionScan(&_opCtx, _coll, params, &ws, nullptr));
+ unique_ptr<CollectionScan> scan(
+ new CollectionScan(_expCtx.get(), _coll, params, &ws, nullptr));
while (!scan->isEOF()) {
WorkingSetID id = WorkingSet::INVALID_ID;
PlanStage::StageState state = scan->work(&id);
@@ -146,11 +148,8 @@ public:
unique_ptr<WorkingSet> ws(new WorkingSet);
- const CollatorInterface* collator = nullptr;
- const boost::intrusive_ptr<ExpressionContext> expCtx(
- new ExpressionContext(&_opCtx, collator, kTestNss));
StatusWithMatchExpression statusWithMatcher =
- MatchExpressionParser::parse(request.getQuery(), expCtx);
+ MatchExpressionParser::parse(request.getQuery(), _expCtx);
ASSERT(statusWithMatcher.isOK());
unique_ptr<MatchExpression> expression = std::move(statusWithMatcher.getValue());
@@ -161,7 +160,7 @@ public:
scan = createCollScan(expression.get(), ws.get());
}
- CountStage countStage(&_opCtx,
+ CountStage countStage(_expCtx.get(),
_coll,
request.getLimit().value_or(0),
request.getSkip().value_or(0),
@@ -216,14 +215,14 @@ public:
params.direction = 1;
// This child stage gets owned and freed by its parent CountStage
- return new IndexScan(&_opCtx, params, ws, expr);
+ return new IndexScan(_expCtx.get(), params, ws, expr);
}
CollectionScan* createCollScan(MatchExpression* expr, WorkingSet* ws) {
CollectionScanParams params;
// This child stage gets owned and freed by its parent CountStage
- return new CollectionScan(&_opCtx, _coll, params, ws, expr);
+ return new CollectionScan(_expCtx.get(), _coll, params, ws, expr);
}
static const char* ns() {
@@ -240,6 +239,7 @@ protected:
OperationContext& _opCtx = *_opCtxPtr;
Lock::DBLock _dbLock;
OldClientContext _ctx;
+ boost::intrusive_ptr<ExpressionContext> _expCtx;
Collection* _coll;
};