diff options
Diffstat (limited to 'src/mongo/db/exec/distinct_scan.h')
-rw-r--r-- | src/mongo/db/exec/distinct_scan.h | 124 |
1 files changed, 62 insertions, 62 deletions
diff --git a/src/mongo/db/exec/distinct_scan.h b/src/mongo/db/exec/distinct_scan.h index d87f5249535..10f850d5a2a 100644 --- a/src/mongo/db/exec/distinct_scan.h +++ b/src/mongo/db/exec/distinct_scan.h @@ -39,87 +39,87 @@ namespace mongo { - class IndexAccessMethod; - class IndexDescriptor; - class WorkingSet; +class IndexAccessMethod; +class IndexDescriptor; +class WorkingSet; - struct DistinctParams { - DistinctParams() : descriptor(NULL), - direction(1), - fieldNo(0) { } +struct DistinctParams { + DistinctParams() : descriptor(NULL), direction(1), fieldNo(0) {} - // What index are we traversing? - const IndexDescriptor* descriptor; + // What index are we traversing? + const IndexDescriptor* descriptor; - // And in what direction? - int direction; + // And in what direction? + int direction; - // What are the bounds? - IndexBounds bounds; + // What are the bounds? + IndexBounds bounds; - // What field in the index's key pattern is the one we're distinct-ing over? - // For example: - // If we have an index {a:1, b:1} we could use it to distinct over either 'a' or 'b'. - // If we distinct over 'a' the position is 0. - // If we distinct over 'b' the position is 1. - int fieldNo; - }; + // What field in the index's key pattern is the one we're distinct-ing over? + // For example: + // If we have an index {a:1, b:1} we could use it to distinct over either 'a' or 'b'. + // If we distinct over 'a' the position is 0. + // If we distinct over 'b' the position is 1. + int fieldNo; +}; - /** - * Used by the distinct command. Executes a mutated index scan over the provided bounds. - * However, rather than looking at every key in the bounds, it skips to the next value of the - * _params.fieldNo-th indexed field. This is because distinct only cares about distinct values - * for that field, so there is no point in examining all keys with the same value for that - * field. - * - * Only created through the getExecutorDistinct path. See db/query/get_executor.cpp - */ - class DistinctScan : public PlanStage { - public: - DistinctScan(OperationContext* txn, const DistinctParams& params, WorkingSet* workingSet); - virtual ~DistinctScan() { } +/** + * Used by the distinct command. Executes a mutated index scan over the provided bounds. + * However, rather than looking at every key in the bounds, it skips to the next value of the + * _params.fieldNo-th indexed field. This is because distinct only cares about distinct values + * for that field, so there is no point in examining all keys with the same value for that + * field. + * + * Only created through the getExecutorDistinct path. See db/query/get_executor.cpp + */ +class DistinctScan : public PlanStage { +public: + DistinctScan(OperationContext* txn, const DistinctParams& params, WorkingSet* workingSet); + virtual ~DistinctScan() {} - 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 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 std::vector<PlanStage*> getChildren() const; + virtual std::vector<PlanStage*> getChildren() const; - virtual StageType stageType() const { return STAGE_DISTINCT_SCAN; } + virtual StageType stageType() const { + return STAGE_DISTINCT_SCAN; + } - 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: - // transactional context for read locks. Not owned by us - OperationContext* _txn; +private: + // transactional context for read locks. Not owned by us + OperationContext* _txn; - // The WorkingSet we annotate with results. Not owned by us. - WorkingSet* _workingSet; + // The WorkingSet we annotate with results. Not owned by us. + WorkingSet* _workingSet; - // Index access. - const IndexDescriptor* _descriptor; // owned by Collection -> IndexCatalog - const IndexAccessMethod* _iam; // owned by Collection -> IndexCatalog + // Index access. + const IndexDescriptor* _descriptor; // owned by Collection -> IndexCatalog + const IndexAccessMethod* _iam; // owned by Collection -> IndexCatalog - // The cursor we use to navigate the tree. - std::unique_ptr<SortedDataInterface::Cursor> _cursor; + // The cursor we use to navigate the tree. + std::unique_ptr<SortedDataInterface::Cursor> _cursor; - DistinctParams _params; + DistinctParams _params; - // _checker gives us our start key and ensures we stay in bounds. - IndexBoundsChecker _checker; - IndexSeekPoint _seekPoint; + // _checker gives us our start key and ensures we stay in bounds. + IndexBoundsChecker _checker; + IndexSeekPoint _seekPoint; - // Stats - CommonStats _commonStats; - DistinctScanStats _specificStats; - }; + // Stats + CommonStats _commonStats; + DistinctScanStats _specificStats; +}; } // namespace mongo |