Storage Engine API
mongo::WiredTigerRecordStore::RandomCursor Class Referencefinal
Inheritance diagram for mongo::WiredTigerRecordStore::RandomCursor:
mongo::RecordCursor

Public Member Functions

 RandomCursor (OperationContext *opCtx, const WiredTigerRecordStore &rs, StringData config)
 
 ~RandomCursor ()
 
boost::optional< Recordnext () final
 Moves forward and returns the new data or boost::none if there is no more data. 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...
 
- Public Member Functions inherited from mongo::RecordCursor
virtual ~RecordCursor ()=default
 
virtual void invalidate (OperationContext *opCtx, const RecordId &id)
 Inform the cursor that this id is being invalidated. More...
 
virtual std::unique_ptr< RecordFetcherfetcherForNext () const
 Returns a RecordFetcher if needed for a call to next() or none if unneeded. More...
 

Private Attributes

WT_CURSOR * _cursor
 
const WiredTigerRecordStore_rs
 
OperationContext * _opCtx
 
const std::string _config
 

Constructor & Destructor Documentation

◆ RandomCursor()

mongo::WiredTigerRecordStore::RandomCursor::RandomCursor ( OperationContext *  opCtx,
const WiredTigerRecordStore rs,
StringData  config 
)
inline

◆ ~RandomCursor()

mongo::WiredTigerRecordStore::RandomCursor::~RandomCursor ( )
inline

Member Function Documentation

◆ detachFromOperationContext()

void mongo::WiredTigerRecordStore::RandomCursor::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.

◆ next()

boost::optional<Record> mongo::WiredTigerRecordStore::RandomCursor::next ( )
inlinefinalvirtual

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.

◆ reattachToOperationContext()

void mongo::WiredTigerRecordStore::RandomCursor::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::WiredTigerRecordStore::RandomCursor::restore ( )
inlinefinalvirtual

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::WiredTigerRecordStore::RandomCursor::save ( )
inlinefinalvirtual

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.

Member Data Documentation

◆ _config

const std::string mongo::WiredTigerRecordStore::RandomCursor::_config
private

◆ _cursor

WT_CURSOR* mongo::WiredTigerRecordStore::RandomCursor::_cursor
private

◆ _opCtx

OperationContext* mongo::WiredTigerRecordStore::RandomCursor::_opCtx
private

◆ _rs

const WiredTigerRecordStore* mongo::WiredTigerRecordStore::RandomCursor::_rs
private

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