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/db/ops | |
parent | d4ff82a11019aef87701db9053499461601e75d6 (diff) | |
download | mongo-5ada96cbe318734f9c7dfa26dea3f28dbe4627bf.tar.gz |
SERVER-53060 Remove QueryRequest class
Diffstat (limited to 'src/mongo/db/ops')
-rw-r--r-- | src/mongo/db/ops/parsed_delete.cpp | 22 | ||||
-rw-r--r-- | src/mongo/db/ops/parsed_update.cpp | 27 |
2 files changed, 26 insertions, 23 deletions
diff --git a/src/mongo/db/ops/parsed_delete.cpp b/src/mongo/db/ops/parsed_delete.cpp index e2bc0f0432f..0837f51addc 100644 --- a/src/mongo/db/ops/parsed_delete.cpp +++ b/src/mongo/db/ops/parsed_delete.cpp @@ -90,12 +90,11 @@ Status ParsedDelete::parseQueryToCQ() { // The projection needs to be applied after the delete operation, so we do not specify a // projection during canonicalization. - auto qr = std::make_unique<QueryRequest>(_request->getNsString()); - qr->setFilter(_request->getQuery()); - qr->setSort(_request->getSort()); - qr->setCollation(_request->getCollation()); - qr->setExplain(_request->getIsExplain()); - qr->setHint(_request->getHint()); + auto findCommand = std::make_unique<FindCommand>(_request->getNsString()); + findCommand->setFilter(_request->getQuery().getOwned()); + findCommand->setSort(_request->getSort().getOwned()); + findCommand->setCollation(_request->getCollation().getOwned()); + findCommand->setHint(_request->getHint()); // Limit should only used for the findAndModify command when a sort is specified. If a sort // is requested, we want to use a top-k sort for efficiency reasons, so should pass the @@ -104,19 +103,20 @@ Status ParsedDelete::parseQueryToCQ() { // has not actually deleted a document. This behavior is fine for findAndModify, but should // not apply to deletes in general. if (!_request->getMulti() && !_request->getSort().isEmpty()) { - qr->setLimit(1); + findCommand->setLimit(1); } // If the delete request has runtime constants or let parameters attached to it, pass them to - // the QueryRequest. + // the FindCommand. if (auto& runtimeConstants = _request->getLegacyRuntimeConstants()) - qr->setLegacyRuntimeConstants(*runtimeConstants); + findCommand->setLegacyRuntimeConstants(*runtimeConstants); if (auto& letParams = _request->getLet()) - qr->setLetParameters(*letParams); + findCommand->setLet(*letParams); auto statusWithCQ = CanonicalQuery::canonicalize(_opCtx, - std::move(qr), + std::move(findCommand), + _request->getIsExplain(), _expCtx, extensionsCallback, MatchExpressionParser::kAllowAllSpecialFeatures); diff --git a/src/mongo/db/ops/parsed_update.cpp b/src/mongo/db/ops/parsed_update.cpp index c21933d9876..fbdc4e0a43e 100644 --- a/src/mongo/db/ops/parsed_update.cpp +++ b/src/mongo/db/ops/parsed_update.cpp @@ -122,15 +122,14 @@ Status ParsedUpdate::parseQueryToCQ() { // The projection needs to be applied after the update operation, so we do not specify a // projection during canonicalization. - auto qr = std::make_unique<QueryRequest>(_request->getNamespaceString()); - qr->setFilter(_request->getQuery()); - qr->setSort(_request->getSort()); - qr->setExplain(static_cast<bool>(_request->explain())); - qr->setHint(_request->getHint()); + auto findCommand = std::make_unique<FindCommand>(_request->getNamespaceString()); + findCommand->setFilter(_request->getQuery()); + findCommand->setSort(_request->getSort()); + findCommand->setHint(_request->getHint()); // We get the collation off the ExpressionContext because it may contain a collection-default // collator if no collation was included in the user's request. - qr->setCollation(_expCtx->getCollatorBSON()); + findCommand->setCollation(_expCtx->getCollatorBSON()); // Limit should only used for the findAndModify command when a sort is specified. If a sort // is requested, we want to use a top-k sort for efficiency reasons, so should pass the @@ -139,7 +138,7 @@ Status ParsedUpdate::parseQueryToCQ() { // has not actually updated a document. This behavior is fine for findAndModify, but should // not apply to update in general. if (!_request->isMulti() && !_request->getSort().isEmpty()) { - qr->setLimit(1); + findCommand->setLimit(1); } // $expr is not allowed in the query for an upsert, since it is not clear what the equality @@ -151,16 +150,20 @@ Status ParsedUpdate::parseQueryToCQ() { } // If the update request has runtime constants or let parameters attached to it, pass them to - // the QueryRequest. + // the FindCommand. if (auto& runtimeConstants = _request->getLegacyRuntimeConstants()) { - qr->setLegacyRuntimeConstants(*runtimeConstants); + findCommand->setLegacyRuntimeConstants(*runtimeConstants); } if (auto& letParams = _request->getLetParameters()) { - qr->setLetParameters(*letParams); + findCommand->setLet(*letParams); } - auto statusWithCQ = CanonicalQuery::canonicalize( - _opCtx, std::move(qr), _expCtx, _extensionsCallback, allowedMatcherFeatures); + auto statusWithCQ = CanonicalQuery::canonicalize(_opCtx, + std::move(findCommand), + static_cast<bool>(_request->explain()), + _expCtx, + _extensionsCallback, + allowedMatcherFeatures); if (statusWithCQ.isOK()) { _canonicalQuery = std::move(statusWithCQ.getValue()); } |