diff options
author | Ruoxin Xu <ruoxin.xu@mongodb.com> | 2021-02-02 21:03:25 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2021-02-17 11:23:05 +0000 |
commit | 5ada96cbe318734f9c7dfa26dea3f28dbe4627bf (patch) | |
tree | 5a63211f065b1e40e5eeeb239d241355e1720ffa /src/mongo/dbtests/query_stage_subplan.cpp | |
parent | d4ff82a11019aef87701db9053499461601e75d6 (diff) | |
download | mongo-5ada96cbe318734f9c7dfa26dea3f28dbe4627bf.tar.gz |
SERVER-53060 Remove QueryRequest class
Diffstat (limited to 'src/mongo/dbtests/query_stage_subplan.cpp')
-rw-r--r-- | src/mongo/dbtests/query_stage_subplan.cpp | 62 |
1 files changed, 32 insertions, 30 deletions
diff --git a/src/mongo/dbtests/query_stage_subplan.cpp b/src/mongo/dbtests/query_stage_subplan.cpp index afbfc280c15..1a63e655cf9 100644 --- a/src/mongo/dbtests/query_stage_subplan.cpp +++ b/src/mongo/dbtests/query_stage_subplan.cpp @@ -97,11 +97,13 @@ protected: bool isExplain = false; // If there is no '$db', append it. auto cmd = OpMsgRequest::fromDBAndBody("test", cmdObj).body; - auto qr = QueryRequest::makeFromFindCommandForTests(cmd, isExplain, NamespaceString()); + auto findCommand = + query_request_helper::makeFromFindCommandForTests(cmd, NamespaceString()); auto cq = unittest::assertGet( CanonicalQuery::canonicalize(opCtx(), - std::move(qr), + std::move(findCommand), + isExplain, expCtx(), ExtensionsCallbackNoop(), MatchExpressionParser::kAllowAllSpecialFeatures)); @@ -135,9 +137,9 @@ TEST_F(QueryStageSubplanTest, QueryStageSubplanGeo2dOr) { "{$or: [{a: {$geoWithin: {$centerSphere: [[0,0],10]}}}," "{a: {$geoWithin: {$centerSphere: [[1,1],10]}}}]}"); - auto qr = std::make_unique<QueryRequest>(nss); - qr->setFilter(query); - auto statusWithCQ = CanonicalQuery::canonicalize(opCtx(), std::move(qr)); + auto findCommand = std::make_unique<FindCommand>(nss); + findCommand->setFilter(query); + auto statusWithCQ = CanonicalQuery::canonicalize(opCtx(), std::move(findCommand)); ASSERT_OK(statusWithCQ.getStatus()); std::unique_ptr<CanonicalQuery> cq = std::move(statusWithCQ.getValue()); @@ -172,9 +174,9 @@ void assertSubplanFromCache(QueryStageSubplanTest* test, const dbtests::WriteCon CollectionPtr collection = ctx.getCollection(); - auto qr = std::make_unique<QueryRequest>(nss); - qr->setFilter(query); - auto statusWithCQ = CanonicalQuery::canonicalize(test->opCtx(), std::move(qr)); + auto findCommand = std::make_unique<FindCommand>(nss); + findCommand->setFilter(query); + auto statusWithCQ = CanonicalQuery::canonicalize(test->opCtx(), std::move(findCommand)); ASSERT_OK(statusWithCQ.getStatus()); std::unique_ptr<CanonicalQuery> cq = std::move(statusWithCQ.getValue()); @@ -256,9 +258,9 @@ TEST_F(QueryStageSubplanTest, QueryStageSubplanDontCacheZeroResults) { CollectionPtr collection = ctx.getCollection(); - auto qr = std::make_unique<QueryRequest>(nss); - qr->setFilter(query); - auto statusWithCQ = CanonicalQuery::canonicalize(opCtx(), std::move(qr)); + auto findCommand = std::make_unique<FindCommand>(nss); + findCommand->setFilter(query); + auto statusWithCQ = CanonicalQuery::canonicalize(opCtx(), std::move(findCommand)); ASSERT_OK(statusWithCQ.getStatus()); std::unique_ptr<CanonicalQuery> cq = std::move(statusWithCQ.getValue()); @@ -312,9 +314,9 @@ TEST_F(QueryStageSubplanTest, QueryStageSubplanDontCacheTies) { CollectionPtr collection = ctx.getCollection(); - auto qr = std::make_unique<QueryRequest>(nss); - qr->setFilter(query); - auto statusWithCQ = CanonicalQuery::canonicalize(opCtx(), std::move(qr)); + auto findCommand = std::make_unique<FindCommand>(nss); + findCommand->setFilter(query); + auto statusWithCQ = CanonicalQuery::canonicalize(opCtx(), std::move(findCommand)); ASSERT_OK(statusWithCQ.getStatus()); std::unique_ptr<CanonicalQuery> cq = std::move(statusWithCQ.getValue()); @@ -484,10 +486,10 @@ TEST_F(QueryStageSubplanTest, QueryStageSubplanPlanRootedOrNE) { insert(BSON("_id" << 3 << "a" << 3)); insert(BSON("_id" << 4)); - auto qr = std::make_unique<QueryRequest>(nss); - qr->setFilter(fromjson("{$or: [{a: 1}, {a: {$ne:1}}]}")); - qr->setSort(BSON("d" << 1)); - auto cq = unittest::assertGet(CanonicalQuery::canonicalize(opCtx(), std::move(qr))); + auto findCommand = std::make_unique<FindCommand>(nss); + findCommand->setFilter(fromjson("{$or: [{a: 1}, {a: {$ne:1}}]}")); + findCommand->setSort(BSON("d" << 1)); + auto cq = unittest::assertGet(CanonicalQuery::canonicalize(opCtx(), std::move(findCommand))); CollectionPtr collection = ctx.getCollection(); @@ -517,10 +519,10 @@ TEST_F(QueryStageSubplanTest, QueryStageSubplanPlanRootedOrNE) { TEST_F(QueryStageSubplanTest, ShouldReportErrorIfExceedsTimeLimitDuringPlanning) { dbtests::WriteContextForTests ctx(opCtx(), nss.ns()); // Build a query with a rooted $or. - auto queryRequest = std::make_unique<QueryRequest>(nss); - queryRequest->setFilter(BSON("$or" << BSON_ARRAY(BSON("p1" << 1) << BSON("p2" << 2)))); + auto findCommand = std::make_unique<FindCommand>(nss); + findCommand->setFilter(BSON("$or" << BSON_ARRAY(BSON("p1" << 1) << BSON("p2" << 2)))); auto canonicalQuery = - uassertStatusOK(CanonicalQuery::canonicalize(opCtx(), std::move(queryRequest))); + uassertStatusOK(CanonicalQuery::canonicalize(opCtx(), std::move(findCommand))); // Add 4 indices: 2 for each predicate to choose from. addIndex(BSON("p1" << 1 << "opt1" << 1)); @@ -550,10 +552,10 @@ TEST_F(QueryStageSubplanTest, ShouldReportErrorIfExceedsTimeLimitDuringPlanning) TEST_F(QueryStageSubplanTest, ShouldReportErrorIfKilledDuringPlanning) { dbtests::WriteContextForTests ctx(opCtx(), nss.ns()); // Build a query with a rooted $or. - auto queryRequest = std::make_unique<QueryRequest>(nss); - queryRequest->setFilter(BSON("$or" << BSON_ARRAY(BSON("p1" << 1) << BSON("p2" << 2)))); + auto findCommand = std::make_unique<FindCommand>(nss); + findCommand->setFilter(BSON("$or" << BSON_ARRAY(BSON("p1" << 1) << BSON("p2" << 2)))); auto canonicalQuery = - uassertStatusOK(CanonicalQuery::canonicalize(opCtx(), std::move(queryRequest))); + uassertStatusOK(CanonicalQuery::canonicalize(opCtx(), std::move(findCommand))); // Add 4 indices: 2 for each predicate to choose from. addIndex(BSON("p1" << 1 << "opt1" << 1)); @@ -587,10 +589,10 @@ TEST_F(QueryStageSubplanTest, ShouldThrowOnRestoreIfIndexDroppedBeforePlanSelect } // Build a query with a rooted $or. - auto queryRequest = std::make_unique<QueryRequest>(nss); - queryRequest->setFilter(BSON("$or" << BSON_ARRAY(BSON("p1" << 1) << BSON("p2" << 2)))); + auto findCommand = std::make_unique<FindCommand>(nss); + findCommand->setFilter(BSON("$or" << BSON_ARRAY(BSON("p1" << 1) << BSON("p2" << 2)))); auto canonicalQuery = - uassertStatusOK(CanonicalQuery::canonicalize(opCtx(), std::move(queryRequest))); + uassertStatusOK(CanonicalQuery::canonicalize(opCtx(), std::move(findCommand))); boost::optional<AutoGetCollectionForReadCommand> collLock; collLock.emplace(opCtx(), nss); @@ -633,10 +635,10 @@ TEST_F(QueryStageSubplanTest, ShouldNotThrowOnRestoreIfIndexDroppedAfterPlanSele } // Build a query with a rooted $or. - auto queryRequest = std::make_unique<QueryRequest>(nss); - queryRequest->setFilter(BSON("$or" << BSON_ARRAY(BSON("p1" << 1) << BSON("p2" << 2)))); + auto findCommand = std::make_unique<FindCommand>(nss); + findCommand->setFilter(BSON("$or" << BSON_ARRAY(BSON("p1" << 1) << BSON("p2" << 2)))); auto canonicalQuery = - uassertStatusOK(CanonicalQuery::canonicalize(opCtx(), std::move(queryRequest))); + uassertStatusOK(CanonicalQuery::canonicalize(opCtx(), std::move(findCommand))); boost::optional<AutoGetCollectionForReadCommand> collLock; collLock.emplace(opCtx(), nss); |