Storage Engine API
mongo::WiredTigerRecordStoreCursorBase Class Referenceabstract

#include <wiredtiger_record_store.h>

Inheritance diagram for mongo::WiredTigerRecordStoreCursorBase:
mongo::SeekableRecordCursor mongo::RecordCursor mongo::WiredTigerRecordStorePrefixedCursor mongo::WiredTigerRecordStoreStandardCursor

Public Member Functions

 WiredTigerRecordStoreCursorBase (OperationContext *opCtx, const WiredTigerRecordStore &rs, bool forward)
 
boost::optional< Recordnext ()
 Moves forward and returns the new data or boost::none if there is no more data. More...
 
boost::optional< RecordseekExact (const RecordId &id)
 Seeks to a Record with the provided id. More...
 
void save ()
 Prepares for state changes in underlying data in a way that allows the cursor's current position to be restored. More...
 
void saveUnpositioned ()
 Prepares for state changes in underlying data without necessarily saving the current state. More...
 
bool restore ()
 Recovers from potential state changes in underlying data. More...
 
void detachFromOperationContext ()
 Detaches from the OperationContext and releases any storage-engine state. More...
 
void reattachToOperationContext (OperationContext *opCtx)
 Reattaches to the OperationContext and reacquires any storage-engine state. More...
 
- Public Member Functions inherited from mongo::SeekableRecordCursor
virtual std::unique_ptr< RecordFetcherfetcherForId (const RecordId &id) const
 Returns a RecordFetcher if needed to fetch the provided Record or none if unneeded. 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...
 

Protected Member Functions

virtual RecordId getKey (WT_CURSOR *cursor) const =0
 
virtual void setKey (WT_CURSOR *cursor, RecordId id) const =0
 
virtual bool hasWrongPrefix (WT_CURSOR *cursor, RecordId *id) const =0
 Callers must have already checked the return value of a positioning method against 'WT_NOTFOUND'. More...
 
virtual void initCursorToBeginning ()=0
 Called when restoring a cursor that has not been advanced. More...
 

Protected Attributes

const WiredTigerRecordStore_rs
 
OperationContext * _opCtx
 
const bool _forward
 
bool _skipNextAdvance = false
 
boost::optional< WiredTigerCursor_cursor
 
bool _eof = false
 
RecordId _lastReturnedId
 

Private Member Functions

bool isVisible (const RecordId &id)
 

Constructor & Destructor Documentation

◆ WiredTigerRecordStoreCursorBase()

mongo::WiredTigerRecordStoreCursorBase::WiredTigerRecordStoreCursorBase ( OperationContext *  opCtx,
const WiredTigerRecordStore rs,
bool  forward 
)

Member Function Documentation

◆ detachFromOperationContext()

void mongo::WiredTigerRecordStoreCursorBase::detachFromOperationContext ( )
virtual

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.

◆ getKey()

virtual RecordId mongo::WiredTigerRecordStoreCursorBase::getKey ( WT_CURSOR *  cursor) const
protectedpure virtual

◆ hasWrongPrefix()

virtual bool mongo::WiredTigerRecordStoreCursorBase::hasWrongPrefix ( WT_CURSOR *  cursor,
RecordId *  id 
) const
protectedpure virtual

Callers must have already checked the return value of a positioning method against 'WT_NOTFOUND'.

This method allows for additional predicates to be considered on a validly positioned cursor. 'id' is an out parameter. Implementations are not required to fill it in. It's simply a possible optimization to avoid a future 'getKey' call if 'hasWrongPrefix' already did one.

Implemented in mongo::WiredTigerRecordStorePrefixedCursor, and mongo::WiredTigerRecordStoreStandardCursor.

◆ initCursorToBeginning()

virtual void mongo::WiredTigerRecordStoreCursorBase::initCursorToBeginning ( )
protectedpure virtual

Called when restoring a cursor that has not been advanced.

Implemented in mongo::WiredTigerRecordStorePrefixedCursor, and mongo::WiredTigerRecordStoreStandardCursor.

◆ isVisible()

bool mongo::WiredTigerRecordStoreCursorBase::isVisible ( const RecordId &  id)
private

◆ next()

boost::optional< Record > mongo::WiredTigerRecordStoreCursorBase::next ( )
virtual

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::WiredTigerRecordStoreCursorBase::reattachToOperationContext ( OperationContext *  opCtx)
virtual

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::WiredTigerRecordStoreCursorBase::restore ( )
virtual

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::WiredTigerRecordStoreCursorBase::save ( )
virtual

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.

◆ saveUnpositioned()

void mongo::WiredTigerRecordStoreCursorBase::saveUnpositioned ( )
virtual

Prepares for state changes in underlying data without necessarily saving the current state.

The cursor's position when restored is unspecified. Caller is expected to seek rather than call next() following the restore.

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

Reimplemented from mongo::SeekableRecordCursor.

◆ seekExact()

boost::optional< Record > mongo::WiredTigerRecordStoreCursorBase::seekExact ( const RecordId &  id)
virtual

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.

◆ setKey()

virtual void mongo::WiredTigerRecordStoreCursorBase::setKey ( WT_CURSOR *  cursor,
RecordId  id 
) const
protectedpure virtual

Member Data Documentation

◆ _cursor

boost::optional<WiredTigerCursor> mongo::WiredTigerRecordStoreCursorBase::_cursor
protected

◆ _eof

bool mongo::WiredTigerRecordStoreCursorBase::_eof = false
protected

◆ _forward

const bool mongo::WiredTigerRecordStoreCursorBase::_forward
protected

◆ _lastReturnedId

RecordId mongo::WiredTigerRecordStoreCursorBase::_lastReturnedId
protected

◆ _opCtx

OperationContext* mongo::WiredTigerRecordStoreCursorBase::_opCtx
protected

◆ _rs

const WiredTigerRecordStore& mongo::WiredTigerRecordStoreCursorBase::_rs
protected

◆ _skipNextAdvance

bool mongo::WiredTigerRecordStoreCursorBase::_skipNextAdvance = false
protected

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