Storage Engine API
mongo::CappedRecordStoreV1 Class Referencefinal

#include <record_store_v1_capped.h>

Inheritance diagram for mongo::CappedRecordStoreV1:
mongo::RecordStoreV1Base mongo::RecordStore

Public Member Functions

 CappedRecordStoreV1 (OperationContext *opCtx, CappedCallback *collection, StringData ns, RecordStoreV1MetaData *details, ExtentManager *em, bool isSystemIndexes)
 
 ~CappedRecordStoreV1 () final
 
const char * name () const final
 
Status truncate (OperationContext *opCtx) final
 removes all Records More...
 
void cappedTruncateAfter (OperationContext *opCtx, RecordId end, bool inclusive) final
 Truncate documents newer than the document at 'end' from the capped collection. More...
 
std::unique_ptr< SeekableRecordCursorgetCursor (OperationContext *opCtx, bool forward) const final
 Returns a new cursor over this record store. More...
 
std::vector< std::unique_ptr< RecordCursor > > getManyCursors (OperationContext *opCtx) const final
 Returns many RecordCursors that partition the RecordStore into many disjoint sets. More...
 
DiskLoc firstRecord (OperationContext *opCtx, const DiskLoc &startExtent=DiskLoc()) const
 
DiskLoc lastRecord (OperationContext *opCtx, const DiskLoc &startExtent=DiskLoc()) const
 
- Public Member Functions inherited from mongo::RecordStoreV1Base
 RecordStoreV1Base (StringData ns, RecordStoreV1MetaData *details, ExtentManager *em, bool isSystemIndexes)
 
virtual ~RecordStoreV1Base ()
 
virtual long long dataSize (OperationContext *opCtx) const
 The dataSize is an approximation of the sum of the sizes (in bytes) of the documents or entries in the recordStore. More...
 
virtual long long numRecords (OperationContext *opCtx) const
 Total number of record in the RecordStore. More...
 
virtual int64_t storageSize (OperationContext *opCtx, BSONObjBuilder *extraInfo=NULL, int level=0) const
 
virtual RecordData dataFor (OperationContext *opCtx, const RecordId &loc) const
 Get the RecordData at loc, which must exist. More...
 
virtual bool findRecord (OperationContext *opCtx, const RecordId &loc, RecordData *rd) const
 
void deleteRecord (OperationContext *opCtx, const RecordId &dl)
 
StatusWith< RecordId > insertRecord (OperationContext *opCtx, const char *data, int len, Timestamp, bool enforceQuota)
 
Status insertRecordsWithDocWriter (OperationContext *opCtx, const DocWriter *const *docs, const Timestamp *, size_t nDocs, RecordId *idsOut) final
 Inserts nDocs documents into this RecordStore using the DocWriter interface. More...
 
virtual Status updateRecord (OperationContext *opCtx, const RecordId &oldLocation, const char *data, int len, bool enforceQuota, UpdateNotifier *notifier)
 
virtual bool updateWithDamagesSupported () const
 
virtual StatusWith< RecordDataupdateWithDamages (OperationContext *opCtx, const RecordId &loc, const RecordData &oldRec, const char *damageSource, const mutablebson::DamageVector &damages)
 Updates the record positioned at 'loc' in-place using the deltas described by 'damages'. More...
 
virtual std::unique_ptr< RecordCursorgetCursorForRepair (OperationContext *opCtx) const
 Constructs a cursor over a potentially corrupted store, which can be used to salvage damaged records. More...
 
void increaseStorageSize (OperationContext *opCtx, int size, bool enforceQuota)
 
virtual Status validate (OperationContext *opCtx, ValidateCmdLevel level, ValidateAdaptor *adaptor, ValidateResults *results, BSONObjBuilder *output)
 
virtual void appendCustomStats (OperationContext *opCtx, BSONObjBuilder *result, double scale) const
 
virtual Status touch (OperationContext *opCtx, BSONObjBuilder *output) const
 Load all data into cache. More...
 
const RecordStoreV1MetaDatadetails () const
 
DiskLoc getExtentLocForRecord (OperationContext *opCtx, const DiskLoc &loc) const
 
DiskLoc getNextRecord (OperationContext *opCtx, const DiskLoc &loc) const
 
DiskLoc getPrevRecord (OperationContext *opCtx, const DiskLoc &loc) const
 
DiskLoc getNextRecordInExtent (OperationContext *opCtx, const DiskLoc &loc) const
 
DiskLoc getPrevRecordInExtent (OperationContext *opCtx, const DiskLoc &loc) const
 
void waitForAllEarlierOplogWritesToBeVisible (OperationContext *opCtx) const override
 Waits for all writes that completed before this call to be visible to forward scans. More...
 
virtual void updateStatsAfterRepair (OperationContext *opCtx, long long numRecords, long long dataSize)
 Called after a repair operation is run with the recomputed numRecords and dataSize. More...
 
- Public Member Functions inherited from mongo::RecordStore
 RecordStore (StringData ns)
 
virtual ~RecordStore ()
 
virtual const std::string & ns () const
 
virtual Status insertRecords (OperationContext *opCtx, std::vector< Record > *records, std::vector< Timestamp > *timestamps, bool enforceQuota)
 
StatusWith< RecordId > insertRecordWithDocWriter (OperationContext *opCtx, const DocWriter *doc, Timestamp timestamp)
 A thin wrapper around insertRecordsWithDocWriter() to simplify handling of single DocWriters. More...
 
virtual std::unique_ptr< RecordCursorgetRandomCursor (OperationContext *opCtx) const
 Constructs a cursor over a record store that returns documents in a randomized order, and allows storage engines to provide a more efficient way of random sampling of a record store than MongoDB's default sampling methods, which is used when this method returns {}. More...
 
virtual bool compactSupported () const
 does this RecordStore support the compact operation? More...
 
virtual bool compactsInPlace () const
 Does compact() leave RecordIds alone or can they change. More...
 
virtual Status compact (OperationContext *opCtx, RecordStoreCompactAdaptor *adaptor, const CompactOptions *options, CompactStats *stats)
 Attempt to reduce the storage space used by this RecordStore. More...
 
virtual bool isInRecordIdOrder () const
 Does the RecordStore cursor retrieve its document in RecordId Order? More...
 
virtual boost::optional< RecordId > oplogStartHack (OperationContext *opCtx, const RecordId &startingPosition) const
 Return the RecordId of an oplog entry as close to startingPosition as possible without being higher. More...
 
virtual Status oplogDiskLocRegister (OperationContext *opCtx, const Timestamp &opTime, bool orderedCommit)
 When we write to an oplog, we call this so that if the storage engine supports doc locking, it can manage the visibility of oplog entries to ensure they are ordered. More...
 
virtual Status updateCappedSize (OperationContext *opCtx, long long cappedSize)
 used to support online change oplog size. More...
 

Protected Member Functions

bool isCapped () const final
 
bool shouldPadInserts () const final
 
void setCappedCallback (CappedCallback *cb) final
 
StatusWith< DiskLocallocRecord (OperationContext *opCtx, int lengthWithHeaders, bool enforceQuota) final
 
void addDeletedRec (OperationContext *opCtx, const DiskLoc &dloc) final
 
- Protected Member Functions inherited from mongo::RecordStoreV1Base
virtual MmapV1RecordHeaderrecordFor (const DiskLoc &loc) const
 
const DeletedRecorddeletedRecordFor (const DiskLoc &loc) const
 
virtual DeletedRecorddrec (const DiskLoc &loc) const
 
Extent_getExtent (OperationContext *opCtx, const DiskLoc &loc) const
 
DiskLoc _getExtentLocForRecord (OperationContext *opCtx, const DiskLoc &loc) const
 
DiskLoc _getNextRecord (OperationContext *opCtx, const DiskLoc &loc) const
 
DiskLoc _getPrevRecord (OperationContext *opCtx, const DiskLoc &loc) const
 
DiskLoc _getNextRecordInExtent (OperationContext *opCtx, const DiskLoc &loc) const
 
DiskLoc _getPrevRecordInExtent (OperationContext *opCtx, const DiskLoc &loc) const
 
DiskLoc _findFirstSpot (OperationContext *opCtx, const DiskLoc &extDiskLoc, Extent *e)
 finds the first suitable DiskLoc for data will return the DiskLoc of a newly created DeletedRecord More...
 
void _addRecordToRecListInExtent (OperationContext *opCtx, MmapV1RecordHeader *r, DiskLoc loc)
 add a record to the end of the linked list chain within this extent. More...
 
StatusWith< RecordId > _insertRecord (OperationContext *opCtx, const char *data, int len, bool enforceQuota)
 internal doesn't check inputs or change padding More...
 

Private Member Functions

void _compact (OperationContext *opCtx)
 
DiskLoc cappedFirstDeletedInCurExtent () const
 
void setFirstDeletedInCurExtent (OperationContext *opCtx, const DiskLoc &loc)
 
void cappedCheckMigrate (OperationContext *opCtx)
 
DiskLoc __capAlloc (OperationContext *opCtx, int len)
 
bool inCapExtent (const DiskLoc &dl) const
 
DiskLoc cappedListOfAllDeletedRecords () const
 
DiskLoc cappedLastDelRecLastExtent () const
 
void setListOfAllDeletedRecords (OperationContext *opCtx, const DiskLoc &loc)
 
void setLastDelRecLastExtent (OperationContext *opCtx, const DiskLoc &loc)
 
ExtenttheCapExtent () const
 
bool nextIsInCapExtent (const DiskLoc &dl) const
 
void advanceCapExtent (OperationContext *opCtx, StringData ns)
 
void cappedTruncateLastDelUpdate (OperationContext *opCtx)
 
void cappedTruncateAfter (OperationContext *opCtx, const char *ns, DiskLoc end, bool inclusive)
 Truncate documents newer than the document at 'end' from the capped collection. More...
 
void _maybeComplain (OperationContext *opCtx, int len) const
 

Private Attributes

CappedCallback_cappedCallback
 
OwnedPointerVector< ExtentManager::CacheHint_extentAdvice
 

Friends

class CappedRecordStoreV1Iterator
 

Additional Inherited Members

- Static Public Member Functions inherited from mongo::RecordStoreV1Base
static int quantizeAllocationSpace (int minSize)
 Quantize 'minSize' to the nearest allocation size. More...
 
static bool isQuantized (int recordSize)
 
static int bucket (int size)
 
- Public Attributes inherited from mongo::RecordStoreV1Base
SavedCursorRegistry savedCursors
 
- Static Public Attributes inherited from mongo::RecordStoreV1Base
static const int Buckets = 26
 
static const int MaxAllowedAllocation = 16 * 1024 * 1024 + 512 * 1024
 
static const int bucketSizes []
 
- Protected Attributes inherited from mongo::RecordStoreV1Base
std::unique_ptr< RecordStoreV1MetaData_details
 
ExtentManager_extentManager
 
bool _isSystemIndexes
 
- Protected Attributes inherited from mongo::RecordStore
std::string _ns
 

Constructor & Destructor Documentation

◆ CappedRecordStoreV1()

mongo::CappedRecordStoreV1::CappedRecordStoreV1 ( OperationContext *  opCtx,
CappedCallback collection,
StringData  ns,
RecordStoreV1MetaData details,
ExtentManager em,
bool  isSystemIndexes 
)

◆ ~CappedRecordStoreV1()

mongo::CappedRecordStoreV1::~CappedRecordStoreV1 ( )
final

Member Function Documentation

◆ __capAlloc()

DiskLoc mongo::CappedRecordStoreV1::__capAlloc ( OperationContext *  opCtx,
int  len 
)
private

◆ _compact()

void mongo::CappedRecordStoreV1::_compact ( OperationContext *  opCtx)
private

◆ _maybeComplain()

void mongo::CappedRecordStoreV1::_maybeComplain ( OperationContext *  opCtx,
int  len 
) const
private

◆ addDeletedRec()

void mongo::CappedRecordStoreV1::addDeletedRec ( OperationContext *  opCtx,
const DiskLoc dloc 
)
finalprotectedvirtual

◆ advanceCapExtent()

void mongo::CappedRecordStoreV1::advanceCapExtent ( OperationContext *  opCtx,
StringData  ns 
)
private

◆ allocRecord()

StatusWith< DiskLoc > mongo::CappedRecordStoreV1::allocRecord ( OperationContext *  opCtx,
int  lengthWithHeaders,
bool  enforceQuota 
)
finalprotectedvirtual

◆ cappedCheckMigrate()

void mongo::CappedRecordStoreV1::cappedCheckMigrate ( OperationContext *  opCtx)
private

◆ cappedFirstDeletedInCurExtent()

DiskLoc mongo::CappedRecordStoreV1::cappedFirstDeletedInCurExtent ( ) const
private

◆ cappedLastDelRecLastExtent()

DiskLoc mongo::CappedRecordStoreV1::cappedLastDelRecLastExtent ( ) const
private

◆ cappedListOfAllDeletedRecords()

DiskLoc mongo::CappedRecordStoreV1::cappedListOfAllDeletedRecords ( ) const
private

◆ cappedTruncateAfter() [1/2]

void mongo::CappedRecordStoreV1::cappedTruncateAfter ( OperationContext *  opCtx,
RecordId  end,
bool  inclusive 
)
finalvirtual

Truncate documents newer than the document at 'end' from the capped collection.

The collection cannot be completely emptied using this function. An assertion will be thrown if that is attempted.

Parameters
inclusive- Truncate 'end' as well iff true

Implements mongo::RecordStore.

◆ cappedTruncateAfter() [2/2]

void mongo::CappedRecordStoreV1::cappedTruncateAfter ( OperationContext *  opCtx,
const char *  ns,
DiskLoc  end,
bool  inclusive 
)
private

Truncate documents newer than the document at 'end' from the capped collection.

The collection cannot be completely emptied using this function. An assertion will be thrown if that is attempted.

Parameters
inclusive- Truncate 'end' as well iff true

◆ cappedTruncateLastDelUpdate()

void mongo::CappedRecordStoreV1::cappedTruncateLastDelUpdate ( OperationContext *  opCtx)
private

◆ firstRecord()

DiskLoc mongo::CappedRecordStoreV1::firstRecord ( OperationContext *  opCtx,
const DiskLoc startExtent = DiskLoc() 
) const

◆ getCursor()

std::unique_ptr< SeekableRecordCursor > mongo::CappedRecordStoreV1::getCursor ( OperationContext *  opCtx,
bool  forward 
) const
finalvirtual

Returns a new cursor over this record store.

The cursor is logically positioned before the first (or last if !forward) Record in the collection so that Record will be returned on the first call to next(). Implementations are allowed to lazily seek to the first Record when next() is called rather than doing it on construction.

Implements mongo::RecordStore.

◆ getManyCursors()

vector< std::unique_ptr< RecordCursor > > mongo::CappedRecordStoreV1::getManyCursors ( OperationContext *  opCtx) const
finalvirtual

Returns many RecordCursors that partition the RecordStore into many disjoint sets.

Iterating all returned RecordCursors is equivalent to iterating the full store.

Reimplemented from mongo::RecordStore.

◆ inCapExtent()

bool mongo::CappedRecordStoreV1::inCapExtent ( const DiskLoc dl) const
private

◆ isCapped()

bool mongo::CappedRecordStoreV1::isCapped ( ) const
inlinefinalprotectedvirtual

◆ lastRecord()

DiskLoc mongo::CappedRecordStoreV1::lastRecord ( OperationContext *  opCtx,
const DiskLoc startExtent = DiskLoc() 
) const

◆ name()

const char* mongo::CappedRecordStoreV1::name ( ) const
inlinefinalvirtual

Implements mongo::RecordStore.

◆ nextIsInCapExtent()

bool mongo::CappedRecordStoreV1::nextIsInCapExtent ( const DiskLoc dl) const
private

◆ setCappedCallback()

void mongo::CappedRecordStoreV1::setCappedCallback ( CappedCallback cb)
inlinefinalprotectedvirtual

Reimplemented from mongo::RecordStore.

◆ setFirstDeletedInCurExtent()

void mongo::CappedRecordStoreV1::setFirstDeletedInCurExtent ( OperationContext *  opCtx,
const DiskLoc loc 
)
private

◆ setLastDelRecLastExtent()

void mongo::CappedRecordStoreV1::setLastDelRecLastExtent ( OperationContext *  opCtx,
const DiskLoc loc 
)
private

◆ setListOfAllDeletedRecords()

void mongo::CappedRecordStoreV1::setListOfAllDeletedRecords ( OperationContext *  opCtx,
const DiskLoc loc 
)
private

◆ shouldPadInserts()

bool mongo::CappedRecordStoreV1::shouldPadInserts ( ) const
inlinefinalprotectedvirtual

◆ theCapExtent()

Extent * mongo::CappedRecordStoreV1::theCapExtent ( ) const
private

◆ truncate()

Status mongo::CappedRecordStoreV1::truncate ( OperationContext *  opCtx)
finalvirtual

removes all Records

Implements mongo::RecordStore.

Friends And Related Function Documentation

◆ CappedRecordStoreV1Iterator

friend class CappedRecordStoreV1Iterator
friend

Member Data Documentation

◆ _cappedCallback

CappedCallback* mongo::CappedRecordStoreV1::_cappedCallback
private

◆ _extentAdvice

OwnedPointerVector<ExtentManager::CacheHint> mongo::CappedRecordStoreV1::_extentAdvice
private

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