Storage Engine API
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
mongo::CappedRecordStoreV1Iterator Class Referencefinal

This class iterates over a capped collection identified by 'ns'. More...

#include <record_store_v1_capped_iterator.h>

Inheritance diagram for mongo::CappedRecordStoreV1Iterator:
mongo::SeekableRecordCursor mongo::RecordCursor

Detailed Description

This class iterates over a capped collection identified by 'ns'.

The collection must exist when the constructor is called.

Public Member Functions

 CappedRecordStoreV1Iterator (OperationContext *opCtx, const CappedRecordStoreV1 *collection, bool forward)
 
boost::optional< Recordnext () final
 Moves forward and returns the new data or boost::none if there is no more data. More...
 
boost::optional< RecordseekExact (const RecordId &id) final
 Seeks to a Record with the provided id. More...
 
void save () final
 Prepares for state changes in underlying data in a way that allows the cursor's current position to be restored. More...
 
bool restore () final
 Recovers from potential state changes in underlying data. More...
 
void detachFromOperationContext () final
 Detaches from the OperationContext and releases any storage-engine state. More...
 
void reattachToOperationContext (OperationContext *opCtx) final
 Reattaches to the OperationContext and reacquires any storage-engine state. More...
 
void invalidate (OperationContext *opCtx, const RecordId &dl) final
 Inform the cursor that this id is being invalidated. More...
 
std::unique_ptr< RecordFetcherfetcherForNext () const final
 Returns a RecordFetcher if needed for a call to next() or none if unneeded. More...
 
std::unique_ptr< RecordFetcherfetcherForId (const RecordId &id) const final
 Returns a RecordFetcher if needed to fetch the provided Record or none if unneeded. More...
 
- Public Member Functions inherited from mongo::SeekableRecordCursor
virtual void saveUnpositioned ()
 Prepares for state changes in underlying data without necessarily saving the current state. More...
 
- Public Member Functions inherited from mongo::RecordCursor
virtual ~RecordCursor ()=default
 

Private Member Functions

void advance ()
 
bool isEOF ()
 
DiskLoc getNextCapped (const DiskLoc &dl)
 Internal collection navigation helper methods. More...
 
DiskLoc prevLoop (const DiskLoc &curr)
 
DiskLoc nextLoop (const DiskLoc &prev)
 
Extent_getExtent (const DiskLoc &loc)
 
DiskLoc _getNextRecord (const DiskLoc &loc)
 
DiskLoc _getPrevRecord (const DiskLoc &loc)
 

Private Attributes

OperationContext * _opCtx
 
const CappedRecordStoreV1 *const _recordStore
 
DiskLoc _curr
 
const bool _forward
 
bool _killedByInvalidate = false
 

Constructor & Destructor Documentation

◆ CappedRecordStoreV1Iterator()

mongo::CappedRecordStoreV1Iterator::CappedRecordStoreV1Iterator ( OperationContext *  opCtx,
const CappedRecordStoreV1 collection,
bool  forward 
)

Member Function Documentation

◆ _getExtent()

Extent * mongo::CappedRecordStoreV1Iterator::_getExtent ( const DiskLoc loc)
private

◆ _getNextRecord()

DiskLoc mongo::CappedRecordStoreV1Iterator::_getNextRecord ( const DiskLoc loc)
private

◆ _getPrevRecord()

DiskLoc mongo::CappedRecordStoreV1Iterator::_getPrevRecord ( const DiskLoc loc)
private

◆ advance()

void mongo::CappedRecordStoreV1Iterator::advance ( )
private

◆ detachFromOperationContext()

void mongo::CappedRecordStoreV1Iterator::detachFromOperationContext ( )
inlinefinalvirtual

Detaches from the OperationContext and releases any storage-engine state.

It is only legal to call this when in a "saved" state. While in the "detached" state, it is only legal to call reattachToOperationContext or the destructor. It is not legal to call detachFromOperationContext() while already in the detached state.

Implements mongo::RecordCursor.

◆ fetcherForId()

std::unique_ptr< RecordFetcher > mongo::CappedRecordStoreV1Iterator::fetcherForId ( const RecordId &  id) const
finalvirtual

Returns a RecordFetcher if needed to fetch the provided Record or none if unneeded.

Reimplemented from mongo::SeekableRecordCursor.

◆ fetcherForNext()

std::unique_ptr< RecordFetcher > mongo::CappedRecordStoreV1Iterator::fetcherForNext ( ) const
finalvirtual

Returns a RecordFetcher if needed for a call to next() or none if unneeded.

Reimplemented from mongo::RecordCursor.

◆ getNextCapped()

DiskLoc mongo::CappedRecordStoreV1Iterator::getNextCapped ( const DiskLoc dl)
private

Internal collection navigation helper methods.

◆ invalidate()

void mongo::CappedRecordStoreV1Iterator::invalidate ( OperationContext *  opCtx,
const RecordId &  id 
)
finalvirtual

Inform the cursor that this id is being invalidated.

Must be called between save and restore. The opCtx is that of the operation causing the invalidation, not the opCtx using the cursor.

WARNING: Storage engines other than MMAPv1 should use the default implementation, and not depend on this being called.

Reimplemented from mongo::RecordCursor.

◆ isEOF()

bool mongo::CappedRecordStoreV1Iterator::isEOF ( )
inlineprivate

◆ next()

boost::optional< Record > mongo::CappedRecordStoreV1Iterator::next ( )
finalvirtual

Moves forward and returns the new data or boost::none if there is no more data.

Continues returning boost::none once it reaches EOF.

Implements mongo::RecordCursor.

◆ nextLoop()

DiskLoc mongo::CappedRecordStoreV1Iterator::nextLoop ( const DiskLoc prev)
private

◆ prevLoop()

DiskLoc mongo::CappedRecordStoreV1Iterator::prevLoop ( const DiskLoc curr)
private

◆ reattachToOperationContext()

void mongo::CappedRecordStoreV1Iterator::reattachToOperationContext ( OperationContext *  opCtx)
inlinefinalvirtual

Reattaches to the OperationContext and reacquires any storage-engine state.

It is only legal to call this in the "detached" state. On return, the cursor is left in a "saved" state, so callers must still call restoreState to use this object.

Implements mongo::RecordCursor.

◆ restore()

bool mongo::CappedRecordStoreV1Iterator::restore ( )
finalvirtual

Recovers from potential state changes in underlying data.

Returns false if it is invalid to continue using this iterator. This usually means that capped deletes have caught up to the position of this iterator and continuing could result in missed data.

If the former position no longer exists, but it is safe to continue iterating, the following call to next() will return the next closest position in the direction of the scan, if any.

This handles restoring after either save() or SeekableRecordCursor::saveUnpositioned().

Implements mongo::RecordCursor.

◆ save()

void mongo::CappedRecordStoreV1Iterator::save ( )
finalvirtual

Prepares for state changes in underlying data in a way that allows the cursor's current position to be restored.

It is safe to call save multiple times in a row. No other method (excluding destructor) may be called until successfully restored.

Implements mongo::RecordCursor.

◆ seekExact()

boost::optional< Record > mongo::CappedRecordStoreV1Iterator::seekExact ( const RecordId &  id)
finalvirtual

Seeks to a Record with the provided id.

If an exact match can't be found, boost::none will be returned and the resulting position of the cursor is unspecified.

Implements mongo::SeekableRecordCursor.

Member Data Documentation

◆ _curr

DiskLoc mongo::CappedRecordStoreV1Iterator::_curr
private

◆ _forward

const bool mongo::CappedRecordStoreV1Iterator::_forward
private

◆ _killedByInvalidate

bool mongo::CappedRecordStoreV1Iterator::_killedByInvalidate = false
private

◆ _opCtx

OperationContext* mongo::CappedRecordStoreV1Iterator::_opCtx
private

◆ _recordStore

const CappedRecordStoreV1* const mongo::CappedRecordStoreV1Iterator::_recordStore
private

The documentation for this class was generated from the following files: