![]() |
Storage Engine API
|
A RecordStore that stores all data in-memory. More...
#include <ephemeral_for_test_record_store.h>
A RecordStore that stores all data in-memory.
cappedMaxSize | - required if isCapped. limit uses dataSize() in this impl. |
Classes | |
class | Cursor |
struct | Data |
struct | EphemeralForTestRecord |
class | InsertChange |
class | RemoveChange |
class | ReverseCursor |
class | TruncateChange |
Public Types | |
typedef std::map< RecordId, EphemeralForTestRecord > | Records |
Public Member Functions | |
EphemeralForTestRecordStore (StringData ns, std::shared_ptr< void > *dataInOut, bool isCapped=false, int64_t cappedMaxSize=-1, int64_t cappedMaxDocs=-1, CappedCallback *cappedCallback=nullptr) | |
virtual const char * | name () 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 |
virtual void | deleteRecord (OperationContext *opCtx, const RecordId &dl) |
virtual StatusWith< RecordId > | insertRecord (OperationContext *opCtx, const char *data, int len, Timestamp, bool enforceQuota) |
virtual Status | insertRecordsWithDocWriter (OperationContext *opCtx, const DocWriter *const *docs, const Timestamp *, size_t nDocs, RecordId *idsOut) |
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< RecordData > | updateWithDamages (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... | |
std::unique_ptr< SeekableRecordCursor > | getCursor (OperationContext *opCtx, bool forward) const final |
Returns a new cursor over this record store. More... | |
virtual Status | truncate (OperationContext *opCtx) |
removes all Records More... | |
virtual void | cappedTruncateAfter (OperationContext *opCtx, RecordId end, bool inclusive) |
Truncate documents newer than the document at 'end' from the capped collection. More... | |
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... | |
virtual void | increaseStorageSize (OperationContext *opCtx, int size, bool enforceQuota) |
virtual int64_t | storageSize (OperationContext *opCtx, BSONObjBuilder *extraInfo=NULL, int infoLevel=0) const |
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 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... | |
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... | |
bool | isCapped () const |
void | setCappedCallback (CappedCallback *cb) |
![]() | |
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< RecordCursor > | getCursorForRepair (OperationContext *opCtx) const |
Constructs a cursor over a potentially corrupted store, which can be used to salvage damaged records. More... | |
virtual std::unique_ptr< RecordCursor > | getRandomCursor (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 std::vector< std::unique_ptr< RecordCursor > > | getManyCursors (OperationContext *opCtx) const |
Returns many RecordCursors that partition the RecordStore into many disjoint sets. 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 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 | |
virtual const EphemeralForTestRecord * | recordFor (const RecordId &loc) const |
virtual EphemeralForTestRecord * | recordFor (const RecordId &loc) |
Private Member Functions | |
StatusWith< RecordId > | extractAndCheckLocForOplog (const char *data, int len) const |
RecordId | allocateLoc () |
bool | cappedAndNeedDelete_inlock (OperationContext *opCtx) const |
void | cappedDeleteAsNeeded_inlock (OperationContext *opCtx) |
void | deleteRecord_inlock (OperationContext *opCtx, const RecordId &dl) |
Private Attributes | |
const bool | _isCapped |
const int64_t | _cappedMaxSize |
const int64_t | _cappedMaxDocs |
CappedCallback * | _cappedCallback |
Data *const | _data |
Additional Inherited Members | |
![]() | |
std::string | _ns |
typedef std::map<RecordId, EphemeralForTestRecord> mongo::EphemeralForTestRecordStore::Records |
|
explicit |
|
private |
|
virtual |
scaleSize | - amount by which to scale size metrics appends any custom stats from the RecordStore or other unique stats |
Implements mongo::RecordStore.
|
private |
|
private |
|
virtual |
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.
inclusive | - Truncate 'end' as well iff true |
Implements mongo::RecordStore.
|
virtual |
Get the RecordData at loc, which must exist.
If unowned data is returned, it is valid until the next modification of this Record or the lock on this collection is released.
In general, prefer findRecord or RecordCursor::seekExact since they can tell you if a record has been removed.
Reimplemented from mongo::RecordStore.
|
inlinevirtual |
The dataSize is an approximation of the sum of the sizes (in bytes) of the documents or entries in the recordStore.
Implements mongo::RecordStore.
|
virtual |
Implements mongo::RecordStore.
|
private |
|
private |
|
virtual |
out | - If the record exists, the contents of this are set. |
If unowned data is returned, it is valid until the next modification of this Record or the lock on this collection is released.
In general prefer RecordCursor::seekExact since it can avoid copying data in more storageEngines.
Warning: MMAPv1 cannot detect if RecordIds are valid. Therefore callers should only pass potentially deleted RecordIds to seek methods if they know that MMAPv1 is not the current storage engine. All new storage engines must support detecting the existence of Records.
Reimplemented from mongo::RecordStore.
|
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.
|
virtual |
|
virtual |
Implements mongo::RecordStore.
|
virtual |
Inserts nDocs documents into this RecordStore using the DocWriter interface.
This allows the storage engine to reserve space for a record and have it built in-place rather than building the record then copying it into its destination.
On success, if idsOut is non-null the RecordIds of the inserted records will be written into it. It must have space for nDocs RecordIds.
Implements mongo::RecordStore.
|
inlinevirtual |
Implements mongo::RecordStore.
|
virtual |
Implements mongo::RecordStore.
|
inlinevirtual |
Total number of record in the RecordStore.
You may need to cache it, so this call takes constant time, as it is called often.
Implements mongo::RecordStore.
|
virtual |
Return the RecordId of an oplog entry as close to startingPosition as possible without being higher.
If there are no entries <= startingPosition, return RecordId().
If you don't implement the oplogStartHack, just use the default implementation which returns boost::none.
Reimplemented from mongo::RecordStore.
|
protectedvirtual |
|
protectedvirtual |
|
inlinevirtual |
Reimplemented from mongo::RecordStore.
|
virtual |
extraInfo | - optional more debug info |
level | - optional, level of debug info to put in (higher is more) |
Implements mongo::RecordStore.
|
virtual |
Load all data into cache.
What cache depends on implementation.
If the underlying storage engine does not support the operation, returns ErrorCodes::CommandNotSupported
output | (optional) - where to put detailed stats |
Reimplemented from mongo::RecordStore.
|
virtual |
removes all Records
Implements mongo::RecordStore.
|
virtual |
notifier | - Only used by record stores which do not support doc-locking. Called only in the case of an in-place update. Called just before the in-place write occurs. |
For capped record stores, the record size will never change.
Implements mongo::RecordStore.
|
inlinevirtual |
Called after a repair operation is run with the recomputed numRecords and dataSize.
Implements mongo::RecordStore.
|
virtual |
Updates the record positioned at 'loc' in-place using the deltas described by 'damages'.
The 'damages' vector describes contiguous ranges of 'damageSource' from which to copy and apply byte-level changes to the data.
Implements mongo::RecordStore.
|
virtual |
Implements mongo::RecordStore.
|
virtual |
Implements mongo::RecordStore.
|
inlineoverridevirtual |
Waits for all writes that completed before this call to be visible to forward scans.
See the comment on RecordCursor for more details about the visibility rules.
It is only legal to call this on an oplog. It is illegal to call this inside a WriteUnitOfWork.
Implements mongo::RecordStore.
|
private |
|
private |
|
private |
|
private |
|
private |