From 9c2ed42daa8fbbef4a919c21ec564e2db55e8d60 Mon Sep 17 00:00:00 2001 From: Mark Benvenuto Date: Sat, 20 Jun 2015 00:22:50 -0400 Subject: SERVER-18579: Clang-Format - reformat code, no comment reflow --- src/mongo/db/exec/index_scan.h | 204 ++++++++++++++++++++--------------------- 1 file changed, 101 insertions(+), 103 deletions(-) (limited to 'src/mongo/db/exec/index_scan.h') diff --git a/src/mongo/db/exec/index_scan.h b/src/mongo/db/exec/index_scan.h index 555b00c4beb..d415c3b985b 100644 --- a/src/mongo/db/exec/index_scan.h +++ b/src/mongo/db/exec/index_scan.h @@ -41,145 +41,143 @@ namespace mongo { - class IndexAccessMethod; - class IndexDescriptor; - class WorkingSet; +class IndexAccessMethod; +class IndexDescriptor; +class WorkingSet; - struct IndexScanParams { - IndexScanParams() : descriptor(NULL), - direction(1), - doNotDedup(false), - maxScan(0), - addKeyMetadata(false) { } +struct IndexScanParams { + IndexScanParams() + : descriptor(NULL), direction(1), doNotDedup(false), maxScan(0), addKeyMetadata(false) {} - const IndexDescriptor* descriptor; + const IndexDescriptor* descriptor; - IndexBounds bounds; + IndexBounds bounds; - int direction; + int direction; - bool doNotDedup; + bool doNotDedup; - // How many keys will we look at? - size_t maxScan; + // How many keys will we look at? + size_t maxScan; - // Do we want to add the key as metadata? - bool addKeyMetadata; - }; + // Do we want to add the key as metadata? + bool addKeyMetadata; +}; +/** + * Stage scans over an index from startKey to endKey, returning results that pass the provided + * filter. Internally dedups on RecordId. + * + * Sub-stage preconditions: None. Is a leaf and consumes no stage data. + */ +class IndexScan : public PlanStage { +public: /** - * Stage scans over an index from startKey to endKey, returning results that pass the provided - * filter. Internally dedups on RecordId. - * - * Sub-stage preconditions: None. Is a leaf and consumes no stage data. + * Keeps track of what this index scan is currently doing so that it + * can do the right thing on the next call to work(). */ - class IndexScan : public PlanStage { - public: - - /** - * Keeps track of what this index scan is currently doing so that it - * can do the right thing on the next call to work(). - */ - enum ScanState { - // Need to initialize the underlying index traversal machinery. - INITIALIZING, + enum ScanState { + // Need to initialize the underlying index traversal machinery. + INITIALIZING, - // Skipping keys as directed by the _checker. - NEED_SEEK, + // Skipping keys as directed by the _checker. + NEED_SEEK, - // Retrieving the next key, and applying the filter if necessary. - GETTING_NEXT, + // Retrieving the next key, and applying the filter if necessary. + GETTING_NEXT, - // The index scan is finished. - HIT_END - }; + // The index scan is finished. + HIT_END + }; - IndexScan(OperationContext* txn, - const IndexScanParams& params, - WorkingSet* workingSet, - const MatchExpression* filter); + IndexScan(OperationContext* txn, + const IndexScanParams& params, + WorkingSet* workingSet, + const MatchExpression* filter); - virtual ~IndexScan() { } + virtual ~IndexScan() {} - 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 getChildren() const; + virtual std::vector getChildren() const; - virtual StageType stageType() const { return STAGE_IXSCAN; } + virtual StageType stageType() const { + return STAGE_IXSCAN; + } - 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: - /** - * Initialize the underlying index Cursor, returning first result if any. - */ - boost::optional initIndexScan(); +private: + /** + * Initialize the underlying index Cursor, returning first result if any. + */ + boost::optional initIndexScan(); - // transactional context for read locks. Not owned by us - OperationContext* _txn; + // transactional context for read locks. Not owned by us + OperationContext* _txn; - // The WorkingSet we fill with results. Not owned by us. - WorkingSet* const _workingSet; + // The WorkingSet we fill with results. Not owned by us. + WorkingSet* const _workingSet; - // Index access. - const IndexAccessMethod* const _iam; // owned by Collection -> IndexCatalog - std::unique_ptr _indexCursor; - const BSONObj _keyPattern; + // Index access. + const IndexAccessMethod* const _iam; // owned by Collection -> IndexCatalog + std::unique_ptr _indexCursor; + const BSONObj _keyPattern; - // Keeps track of what work we need to do next. - ScanState _scanState; + // Keeps track of what work we need to do next. + ScanState _scanState; - // Contains expressions only over fields in the index key. We assume this is built - // correctly by whomever creates this class. - // The filter is not owned by us. - const MatchExpression* const _filter; + // Contains expressions only over fields in the index key. We assume this is built + // correctly by whomever creates this class. + // The filter is not owned by us. + const MatchExpression* const _filter; - // Could our index have duplicates? If so, we use _returned to dedup. - bool _shouldDedup; - unordered_set _returned; + // Could our index have duplicates? If so, we use _returned to dedup. + bool _shouldDedup; + unordered_set _returned; - const bool _forward; - const IndexScanParams _params; + const bool _forward; + const IndexScanParams _params; - // Stats - CommonStats _commonStats; - IndexScanStats _specificStats; + // Stats + CommonStats _commonStats; + IndexScanStats _specificStats; - // - // This class employs one of two different algorithms for determining when the index scan - // has reached the end: - // + // + // This class employs one of two different algorithms for determining when the index scan + // has reached the end: + // - // - // 1) If the index scan is not a single contiguous interval, then we use an - // IndexBoundsChecker to determine which keys to return and when to stop scanning. - // In this case, _checker will be non-NULL. - // + // + // 1) If the index scan is not a single contiguous interval, then we use an + // IndexBoundsChecker to determine which keys to return and when to stop scanning. + // In this case, _checker will be non-NULL. + // - std::unique_ptr _checker; - IndexSeekPoint _seekPoint; + std::unique_ptr _checker; + IndexSeekPoint _seekPoint; - // - // 2) If the index scan is a single contiguous interval, then the scan can execute faster by - // letting the index cursor tell us when it hits the end, rather than repeatedly doing - // BSON compares against scanned keys. In this case _checker will be NULL. - // + // + // 2) If the index scan is a single contiguous interval, then the scan can execute faster by + // letting the index cursor tell us when it hits the end, rather than repeatedly doing + // BSON compares against scanned keys. In this case _checker will be NULL. + // - // The key that the index cursor should stop on/after. - BSONObj _endKey; + // The key that the index cursor should stop on/after. + BSONObj _endKey; - // Is the end key included in the range? - bool _endKeyInclusive; - }; + // Is the end key included in the range? + bool _endKeyInclusive; +}; } // namespace mongo -- cgit v1.2.1