diff options
Diffstat (limited to 'src/mongo/db/storage/mmap_v1/record_store_v1_capped_iterator.h')
-rw-r--r-- | src/mongo/db/storage/mmap_v1/record_store_v1_capped_iterator.h | 41 |
1 files changed, 15 insertions, 26 deletions
diff --git a/src/mongo/db/storage/mmap_v1/record_store_v1_capped_iterator.h b/src/mongo/db/storage/mmap_v1/record_store_v1_capped_iterator.h index 99f83b20e7a..de2b6fda5e3 100644 --- a/src/mongo/db/storage/mmap_v1/record_store_v1_capped_iterator.h +++ b/src/mongo/db/storage/mmap_v1/record_store_v1_capped_iterator.h @@ -40,32 +40,25 @@ namespace mongo { /** * This class iterates over a capped collection identified by 'ns'. * The collection must exist when the constructor is called. - * - * If start is not DiskLoc(), the iteration begins at that DiskLoc. - * - * If tailable is true, getNext() can be called after isEOF. It will use the last valid - * returned DiskLoc and try to find the next record from that. */ - class CappedRecordStoreV1Iterator : public RecordIterator { + class CappedRecordStoreV1Iterator final : public RecordCursor { public: CappedRecordStoreV1Iterator( OperationContext* txn, const CappedRecordStoreV1* collection, - const RecordId& start, - bool tailable, - const CollectionScanParams::Direction& dir ); - virtual ~CappedRecordStoreV1Iterator() { } + bool forward ); - // If this is a tailable cursor, isEOF could change its mind after a call to getNext(). - virtual bool isEOF(); - virtual RecordId getNext(); - virtual RecordId curr(); + boost::optional<Record> next() final; + boost::optional<Record> seekExact(const RecordId& id) final; + void savePositioned() final; + bool restore(OperationContext* txn) final; + void invalidate(const RecordId& dl) final; + std::unique_ptr<RecordFetcher> fetcherForNext() const final; + std::unique_ptr<RecordFetcher> fetcherForId(const RecordId& id) const final; - virtual void invalidate(const RecordId& dl); - virtual void saveState(); - virtual bool restoreState(OperationContext* txn); - - virtual RecordData dataFor( const RecordId& loc ) const; private: + void advance(); + bool isEOF() { return _curr.isNull(); } + /** * Internal collection navigation helper methods. */ @@ -82,20 +75,16 @@ namespace mongo { OperationContext* _txn; // The collection we're iterating over. - const CappedRecordStoreV1* _recordStore; + const CappedRecordStoreV1* const _recordStore; // The result returned on the next call to getNext(). DiskLoc _curr; - // If we're tailable, we try to progress from the last valid result when we hit the end. - DiskLoc _prev; - bool _tailable; - - CollectionScanParams::Direction _direction; + const bool _forward; // If invalidate kills the DiskLoc we need to move forward, we kill the iterator. See the // comment in the body of invalidate(...). - bool _killedByInvalidate; + bool _killedByInvalidate = false; }; } // namespace mongo |