summaryrefslogtreecommitdiff
path: root/src/mongo/db/ops/parsed_delete.cpp
diff options
context:
space:
mode:
authorMark Benvenuto <mark.benvenuto@mongodb.com>2015-06-20 00:22:50 -0400
committerMark Benvenuto <mark.benvenuto@mongodb.com>2015-06-20 10:56:02 -0400
commit9c2ed42daa8fbbef4a919c21ec564e2db55e8d60 (patch)
tree3814f79c10d7b490948d8cb7b112ac1dd41ceff1 /src/mongo/db/ops/parsed_delete.cpp
parent01965cf52bce6976637ecb8f4a622aeb05ab256a (diff)
downloadmongo-9c2ed42daa8fbbef4a919c21ec564e2db55e8d60.tar.gz
SERVER-18579: Clang-Format - reformat code, no comment reflow
Diffstat (limited to 'src/mongo/db/ops/parsed_delete.cpp')
-rw-r--r--src/mongo/db/ops/parsed_delete.cpp142
1 files changed, 70 insertions, 72 deletions
diff --git a/src/mongo/db/ops/parsed_delete.cpp b/src/mongo/db/ops/parsed_delete.cpp
index 62243d0818d..46a2a33752d 100644
--- a/src/mongo/db/ops/parsed_delete.cpp
+++ b/src/mongo/db/ops/parsed_delete.cpp
@@ -46,88 +46,86 @@
namespace mongo {
- ParsedDelete::ParsedDelete(OperationContext* txn, const DeleteRequest* request) :
- _txn(txn),
- _request(request) { }
+ParsedDelete::ParsedDelete(OperationContext* txn, const DeleteRequest* request)
+ : _txn(txn), _request(request) {}
- Status ParsedDelete::parseRequest() {
- dassert(!_canonicalQuery.get());
- // It is invalid to request that the DeleteStage return the deleted document during a
- // multi-remove.
- invariant(!(_request->shouldReturnDeleted() && _request->isMulti()));
+Status ParsedDelete::parseRequest() {
+ dassert(!_canonicalQuery.get());
+ // It is invalid to request that the DeleteStage return the deleted document during a
+ // multi-remove.
+ invariant(!(_request->shouldReturnDeleted() && _request->isMulti()));
- // It is invalid to request that a ProjectionStage be applied to the DeleteStage if the
- // DeleteStage would not return the deleted document.
- invariant(_request->getProj().isEmpty() || _request->shouldReturnDeleted());
+ // It is invalid to request that a ProjectionStage be applied to the DeleteStage if the
+ // DeleteStage would not return the deleted document.
+ invariant(_request->getProj().isEmpty() || _request->shouldReturnDeleted());
- if (CanonicalQuery::isSimpleIdQuery(_request->getQuery())) {
- return Status::OK();
- }
-
- return parseQueryToCQ();
+ if (CanonicalQuery::isSimpleIdQuery(_request->getQuery())) {
+ return Status::OK();
}
- Status ParsedDelete::parseQueryToCQ() {
- dassert(!_canonicalQuery.get());
-
- CanonicalQuery* cqRaw;
- const WhereCallbackReal whereCallback(_txn, _request->getNamespaceString().db());
-
- // 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
- // limit through. Generally, a delete stage expects to be able to skip documents that were
- // deleted out from under it, but a limit could inhibit that and give an EOF when the delete
- // has not actually deleted a document. This behavior is fine for findAndModify, but should
- // not apply to deletes in general.
- long long limit = (!_request->isMulti() && !_request->getSort().isEmpty()) ? -1 : 0;
-
- // The projection needs to be applied after the delete operation, so we specify an empty
- // BSONObj as the projection during canonicalization.
- const BSONObj emptyObj;
- Status status = CanonicalQuery::canonicalize(_request->getNamespaceString().ns(),
- _request->getQuery(),
- _request->getSort(),
- emptyObj, // projection
- 0, // skip
- limit,
- emptyObj, // hint
- emptyObj, // min
- emptyObj, // max
- false, // snapshot
- _request->isExplain(),
- &cqRaw,
- whereCallback);
-
- if (status.isOK()) {
- _canonicalQuery.reset(cqRaw);
- }
-
- return status;
+ return parseQueryToCQ();
+}
+
+Status ParsedDelete::parseQueryToCQ() {
+ dassert(!_canonicalQuery.get());
+
+ CanonicalQuery* cqRaw;
+ const WhereCallbackReal whereCallback(_txn, _request->getNamespaceString().db());
+
+ // 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
+ // limit through. Generally, a delete stage expects to be able to skip documents that were
+ // deleted out from under it, but a limit could inhibit that and give an EOF when the delete
+ // has not actually deleted a document. This behavior is fine for findAndModify, but should
+ // not apply to deletes in general.
+ long long limit = (!_request->isMulti() && !_request->getSort().isEmpty()) ? -1 : 0;
+
+ // The projection needs to be applied after the delete operation, so we specify an empty
+ // BSONObj as the projection during canonicalization.
+ const BSONObj emptyObj;
+ Status status = CanonicalQuery::canonicalize(_request->getNamespaceString().ns(),
+ _request->getQuery(),
+ _request->getSort(),
+ emptyObj, // projection
+ 0, // skip
+ limit,
+ emptyObj, // hint
+ emptyObj, // min
+ emptyObj, // max
+ false, // snapshot
+ _request->isExplain(),
+ &cqRaw,
+ whereCallback);
+
+ if (status.isOK()) {
+ _canonicalQuery.reset(cqRaw);
}
- const DeleteRequest* ParsedDelete::getRequest() const {
- return _request;
- }
+ return status;
+}
- bool ParsedDelete::canYield() const {
- return !_request->isGod() &&
- PlanExecutor::YIELD_AUTO == _request->getYieldPolicy() &&
- !isIsolated();
- }
+const DeleteRequest* ParsedDelete::getRequest() const {
+ return _request;
+}
- bool ParsedDelete::isIsolated() const {
- return _canonicalQuery.get()
- ? QueryPlannerCommon::hasNode(_canonicalQuery->root(), MatchExpression::ATOMIC)
- : LiteParsedQuery::isQueryIsolated(_request->getQuery());
- }
+bool ParsedDelete::canYield() const {
+ return !_request->isGod() && PlanExecutor::YIELD_AUTO == _request->getYieldPolicy() &&
+ !isIsolated();
+}
- bool ParsedDelete::hasParsedQuery() const {
- return _canonicalQuery.get() != NULL;
- }
+bool ParsedDelete::isIsolated() const {
+ return _canonicalQuery.get()
+ ? QueryPlannerCommon::hasNode(_canonicalQuery->root(), MatchExpression::ATOMIC)
+ : LiteParsedQuery::isQueryIsolated(_request->getQuery());
+}
- CanonicalQuery* ParsedDelete::releaseParsedQuery() {
- invariant(_canonicalQuery.get() != NULL);
- return _canonicalQuery.release();
- }
+bool ParsedDelete::hasParsedQuery() const {
+ return _canonicalQuery.get() != NULL;
+}
+
+CanonicalQuery* ParsedDelete::releaseParsedQuery() {
+ invariant(_canonicalQuery.get() != NULL);
+ return _canonicalQuery.release();
+}
} // namespace mongo