summaryrefslogtreecommitdiff
path: root/src/mongo/db/exec/and_sorted.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/db/exec/and_sorted.h')
-rw-r--r--src/mongo/db/exec/and_sorted.h110
1 files changed, 56 insertions, 54 deletions
diff --git a/src/mongo/db/exec/and_sorted.h b/src/mongo/db/exec/and_sorted.h
index 424cda280f6..3a25aa8456e 100644
--- a/src/mongo/db/exec/and_sorted.h
+++ b/src/mongo/db/exec/and_sorted.h
@@ -39,77 +39,79 @@
namespace mongo {
- /**
- * Reads from N children, each of which must have a valid RecordId. Assumes each child produces
- * RecordIds in sorted order. Outputs the intersection of the RecordIds outputted by the
- * children.
- *
- * Preconditions: Valid RecordId. More than one child.
- *
- * Any RecordId that we keep a reference to that is invalidated before we are able to return it
- * is fetched and added to the WorkingSet as "flagged for further review." Because this stage
- * operates with RecordIds, we are unable to evaluate the AND for the invalidated RecordId, and it
- * must be fully matched later.
- */
- class AndSortedStage : public PlanStage {
- public:
- AndSortedStage(WorkingSet* ws, const Collection* collection);
- virtual ~AndSortedStage();
+/**
+ * Reads from N children, each of which must have a valid RecordId. Assumes each child produces
+ * RecordIds in sorted order. Outputs the intersection of the RecordIds outputted by the
+ * children.
+ *
+ * Preconditions: Valid RecordId. More than one child.
+ *
+ * Any RecordId that we keep a reference to that is invalidated before we are able to return it
+ * is fetched and added to the WorkingSet as "flagged for further review." Because this stage
+ * operates with RecordIds, we are unable to evaluate the AND for the invalidated RecordId, and it
+ * must be fully matched later.
+ */
+class AndSortedStage : public PlanStage {
+public:
+ AndSortedStage(WorkingSet* ws, const Collection* collection);
+ virtual ~AndSortedStage();
- void addChild(PlanStage* child);
+ void addChild(PlanStage* child);
- virtual StageState work(WorkingSetID* out);
- virtual bool isEOF();
+ virtual StageState work(WorkingSetID* out);
+ virtual bool isEOF();
- 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_AND_SORTED; }
+ virtual StageType stageType() const {
+ return STAGE_AND_SORTED;
+ }
- 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;
- private:
- // Find a node to AND against.
- PlanStage::StageState getTargetLoc(WorkingSetID* out);
+private:
+ // Find a node to AND against.
+ PlanStage::StageState getTargetLoc(WorkingSetID* out);
- // Move a child which hasn't advanced to the target node forward.
- // Returns the target node in 'out' if all children successfully advance to it.
- PlanStage::StageState moveTowardTargetLoc(WorkingSetID* out);
+ // Move a child which hasn't advanced to the target node forward.
+ // Returns the target node in 'out' if all children successfully advance to it.
+ PlanStage::StageState moveTowardTargetLoc(WorkingSetID* out);
- // Not owned by us.
- const Collection* _collection;
+ // Not owned by us.
+ const Collection* _collection;
- // Not owned by us.
- WorkingSet* _ws;
+ // Not owned by us.
+ WorkingSet* _ws;
- // Owned by us.
- std::vector<PlanStage*> _children;
+ // Owned by us.
+ std::vector<PlanStage*> _children;
- // The current node we're AND-ing against.
- size_t _targetNode;
- RecordId _targetLoc;
- WorkingSetID _targetId;
+ // The current node we're AND-ing against.
+ size_t _targetNode;
+ RecordId _targetLoc;
+ WorkingSetID _targetId;
- // Nodes we're moving forward until they hit the element we're AND-ing.
- // Everything in here has not advanced to _targetLoc yet.
- // These are indices into _children.
- std::queue<size_t> _workingTowardRep;
+ // Nodes we're moving forward until they hit the element we're AND-ing.
+ // Everything in here has not advanced to _targetLoc yet.
+ // These are indices into _children.
+ std::queue<size_t> _workingTowardRep;
- // If any child hits EOF or if we have any errors, we're EOF.
- bool _isEOF;
+ // If any child hits EOF or if we have any errors, we're EOF.
+ bool _isEOF;
- // Stats
- CommonStats _commonStats;
- AndSortedStats _specificStats;
- };
+ // Stats
+ CommonStats _commonStats;
+ AndSortedStats _specificStats;
+};
} // namespace mongo