summaryrefslogtreecommitdiff
path: root/src/mongo/db/exec/delete.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/db/exec/delete.h')
-rw-r--r--src/mongo/db/exec/delete.h161
1 files changed, 82 insertions, 79 deletions
diff --git a/src/mongo/db/exec/delete.h b/src/mongo/db/exec/delete.h
index 028cd086279..75556152680 100644
--- a/src/mongo/db/exec/delete.h
+++ b/src/mongo/db/exec/delete.h
@@ -34,109 +34,112 @@
namespace mongo {
- class CanonicalQuery;
- class OperationContext;
- class PlanExecutor;
+class CanonicalQuery;
+class OperationContext;
+class PlanExecutor;
- struct DeleteStageParams {
- DeleteStageParams() :
- isMulti(false),
- shouldCallLogOp(false),
- fromMigrate(false),
- isExplain(false),
- returnDeleted(false),
- canonicalQuery(NULL) { }
+struct DeleteStageParams {
+ DeleteStageParams()
+ : isMulti(false),
+ shouldCallLogOp(false),
+ fromMigrate(false),
+ isExplain(false),
+ returnDeleted(false),
+ canonicalQuery(NULL) {}
- // Should we delete all documents returned from the child (a "multi delete"), or at most one
- // (a "single delete")?
- bool isMulti;
+ // Should we delete all documents returned from the child (a "multi delete"), or at most one
+ // (a "single delete")?
+ bool isMulti;
- // Should we write each delete to the oplog?
- bool shouldCallLogOp;
+ // Should we write each delete to the oplog?
+ bool shouldCallLogOp;
- // Is this delete part of a migrate operation that is essentially like a no-op
- // when the cluster is observed by an external client.
- bool fromMigrate;
+ // Is this delete part of a migrate operation that is essentially like a no-op
+ // when the cluster is observed by an external client.
+ bool fromMigrate;
- // Are we explaining a delete command rather than actually executing it?
- bool isExplain;
+ // Are we explaining a delete command rather than actually executing it?
+ bool isExplain;
- // Should we return the document we just deleted?
- bool returnDeleted;
+ // Should we return the document we just deleted?
+ bool returnDeleted;
- // The parsed query predicate for this delete. Not owned here.
- CanonicalQuery* canonicalQuery;
- };
+ // The parsed query predicate for this delete. Not owned here.
+ CanonicalQuery* canonicalQuery;
+};
- /**
- * This stage delete documents by RecordId that are returned from its child. If the deleted
- * document was requested to be returned, then ADVANCED is returned after deleting a document.
- * Otherwise, NEED_TIME is returned after deleting a document.
- *
- * Callers of work() must be holding a write lock (and, for shouldCallLogOp=true deletes,
- * callers must have had the replication coordinator approve the write).
- */
- class DeleteStage : public PlanStage {
- MONGO_DISALLOW_COPYING(DeleteStage);
- public:
- DeleteStage(OperationContext* txn,
- const DeleteStageParams& params,
- WorkingSet* ws,
- Collection* collection,
- PlanStage* child);
- virtual ~DeleteStage();
+/**
+ * This stage delete documents by RecordId that are returned from its child. If the deleted
+ * document was requested to be returned, then ADVANCED is returned after deleting a document.
+ * Otherwise, NEED_TIME is returned after deleting a document.
+ *
+ * Callers of work() must be holding a write lock (and, for shouldCallLogOp=true deletes,
+ * callers must have had the replication coordinator approve the write).
+ */
+class DeleteStage : public PlanStage {
+ MONGO_DISALLOW_COPYING(DeleteStage);
+
+public:
+ DeleteStage(OperationContext* txn,
+ const DeleteStageParams& params,
+ WorkingSet* ws,
+ Collection* collection,
+ PlanStage* child);
+ virtual ~DeleteStage();
- virtual bool isEOF();
- virtual StageState work(WorkingSetID* out);
+ virtual bool isEOF();
+ virtual StageState work(WorkingSetID* out);
- virtual void saveState();
- virtual void restoreState(OperationContext* opCtx);
- virtual void invalidate(OperationContext* txn, const RecordId& dl, InvalidationType type);
+ virtual void saveState();
+ virtual void restoreState(OperationContext* opCtx);
+ virtual void invalidate(OperationContext* txn, const RecordId& dl, InvalidationType type);
- virtual std::vector<PlanStage*> getChildren() const;
+ virtual std::vector<PlanStage*> getChildren() const;
- virtual StageType stageType() const { return STAGE_DELETE; }
+ virtual StageType stageType() const {
+ return STAGE_DELETE;
+ }
- virtual PlanStageStats* getStats();
+ virtual PlanStageStats* getStats();
- virtual const CommonStats* getCommonStats() const;
+ virtual const CommonStats* getCommonStats() const;
- virtual const SpecificStats* getSpecificStats() const;
+ virtual const SpecificStats* getSpecificStats() const;
- static const char* kStageType;
+ static const char* kStageType;
- /**
- * Extracts the number of documents deleted by the update plan 'exec'.
- *
- * Should only be called if the root plan stage of 'exec' is UPDATE and if 'exec' is EOF.
- */
- static long long getNumDeleted(PlanExecutor* exec);
+ /**
+ * Extracts the number of documents deleted by the update plan 'exec'.
+ *
+ * Should only be called if the root plan stage of 'exec' is UPDATE and if 'exec' is EOF.
+ */
+ static long long getNumDeleted(PlanExecutor* exec);
- private:
- // Transactional context. Not owned by us.
- OperationContext* _txn;
+private:
+ // Transactional context. Not owned by us.
+ OperationContext* _txn;
- DeleteStageParams _params;
+ DeleteStageParams _params;
- // Not owned by us.
- WorkingSet* _ws;
+ // Not owned by us.
+ WorkingSet* _ws;
- // Collection to operate on. Not owned by us. Can be NULL (if NULL, isEOF() will always
- // return true). If non-NULL, the lifetime of the collection must supersede that of the
- // stage.
- Collection* _collection;
+ // Collection to operate on. Not owned by us. Can be NULL (if NULL, isEOF() will always
+ // return true). If non-NULL, the lifetime of the collection must supersede that of the
+ // stage.
+ Collection* _collection;
- std::unique_ptr<PlanStage> _child;
+ std::unique_ptr<PlanStage> _child;
- // If not WorkingSet::INVALID_ID, we use this rather than asking our child what to do next.
- WorkingSetID _idRetrying;
+ // If not WorkingSet::INVALID_ID, we use this rather than asking our child what to do next.
+ WorkingSetID _idRetrying;
- // If not WorkingSet::INVALID_ID, we return this member to our caller.
- WorkingSetID _idReturning;
+ // If not WorkingSet::INVALID_ID, we return this member to our caller.
+ WorkingSetID _idReturning;
- // Stats
- CommonStats _commonStats;
- DeleteStats _specificStats;
- };
+ // Stats
+ CommonStats _commonStats;
+ DeleteStats _specificStats;
+};
} // namespace mongo