![]() |
Storage Engine API
|
#include <collection_impl.h>
Public Types | |
using | ValidationAction = Collection::ValidationAction |
using | ValidationLevel = Collection::ValidationLevel |
Public Member Functions | |
CollectionImpl (Collection *_this, OperationContext *opCtx, StringData fullNS, OptionalCollectionUUID uuid, CollectionCatalogEntry *details, RecordStore *recordStore, DatabaseCatalogEntry *dbce) | |
~CollectionImpl () | |
void | init (OperationContext *opCtx) final |
bool | ok () const final |
CollectionCatalogEntry * | getCatalogEntry () final |
const CollectionCatalogEntry * | getCatalogEntry () const final |
CollectionInfoCache * | infoCache () final |
const CollectionInfoCache * | infoCache () const final |
const NamespaceString & | ns () const final |
OptionalCollectionUUID | uuid () const |
void | refreshUUID (OperationContext *opCtx) final |
const IndexCatalog * | getIndexCatalog () const final |
IndexCatalog * | getIndexCatalog () final |
const RecordStore * | getRecordStore () const final |
RecordStore * | getRecordStore () final |
CursorManager * | getCursorManager () const final |
bool | requiresIdIndex () const final |
Snapshotted< BSONObj > | docFor (OperationContext *opCtx, const RecordId &loc) const final |
bool | findDoc (OperationContext *opCtx, const RecordId &loc, Snapshotted< BSONObj > *out) const final |
std::unique_ptr< SeekableRecordCursor > | getCursor (OperationContext *opCtx, bool forward=true) const final |
std::vector< std::unique_ptr< RecordCursor > > | getManyCursors (OperationContext *opCtx) const final |
Returns many cursors that partition the Collection into many disjoint sets. More... | |
void | deleteDocument (OperationContext *opCtx, StmtId stmtId, const RecordId &loc, OpDebug *opDebug, bool fromMigrate=false, bool noWarn=false, Collection::StoreDeletedDoc storeDeletedDoc=Collection::StoreDeletedDoc::Off) final |
Deletes the document with the given RecordId from the collection. More... | |
Status | insertDocuments (OperationContext *opCtx, std::vector< InsertStatement >::const_iterator begin, std::vector< InsertStatement >::const_iterator end, OpDebug *opDebug, bool enforceQuota, bool fromMigrate=false) final |
Status | insertDocument (OperationContext *opCtx, const InsertStatement &doc, OpDebug *opDebug, bool enforceQuota, bool fromMigrate=false) final |
this does NOT modify the doc before inserting i.e. More... | |
Status | insertDocumentsForOplog (OperationContext *opCtx, const DocWriter *const *docs, Timestamp *timestamps, size_t nDocs) final |
Callers must ensure no document validation is performed for this collection when calling this method. More... | |
Status | insertDocument (OperationContext *opCtx, const BSONObj &doc, const std::vector< MultiIndexBlock *> &indexBlocks, bool enforceQuota) final |
Inserts a document into the record store and adds it to the MultiIndexBlocks passed in. More... | |
RecordId | updateDocument (OperationContext *opCtx, const RecordId &oldLocation, const Snapshotted< BSONObj > &oldDoc, const BSONObj &newDoc, bool enforceQuota, bool indexesAffected, OpDebug *opDebug, OplogUpdateEntryArgs *args) final |
Updates the document @ oldLocation with newDoc. More... | |
bool | updateWithDamagesSupported () const final |
StatusWith< RecordData > | updateDocumentWithDamages (OperationContext *opCtx, const RecordId &loc, const Snapshotted< RecordData > &oldRec, const char *damageSource, const mutablebson::DamageVector &damages, OplogUpdateEntryArgs *args) final |
Not allowed to modify indexes. More... | |
StatusWith< CompactStats > | compact (OperationContext *opCtx, const CompactOptions *options) final |
Status | truncate (OperationContext *opCtx) final |
removes all documents as fast as possible indexes before and after will be the same as will other characteristics More... | |
Status | validate (OperationContext *opCtx, ValidateCmdLevel level, bool background, std::unique_ptr< Lock::CollectionLock > collLk, ValidateResults *results, BSONObjBuilder *output) final |
Status | touch (OperationContext *opCtx, bool touchData, bool touchIndexes, BSONObjBuilder *output) const final |
forces data into cache More... | |
void | cappedTruncateAfter (OperationContext *opCtx, RecordId end, bool inclusive) final |
Truncate documents newer than the document at 'end' from the capped collection. More... | |
StatusWithMatchExpression | parseValidator (OperationContext *opCtx, const BSONObj &validator, MatchExpressionParser::AllowedFeatureSet allowedFeatures, boost::optional< ServerGlobalParams::FeatureCompatibility::Version > maxFeatureCompatibilityVersion=boost::none) const final |
Returns a non-ok Status if validator is not legal for this collection. More... | |
Status | setValidator (OperationContext *opCtx, BSONObj validator) final |
Sets the validator for this collection. More... | |
Status | setValidationLevel (OperationContext *opCtx, StringData newLevel) final |
Status | setValidationAction (OperationContext *opCtx, StringData newAction) final |
StringData | getValidationLevel () const final |
StringData | getValidationAction () const final |
Status | updateValidator (OperationContext *opCtx, BSONObj newValidator, StringData newLevel, StringData newAction) final |
Sets the validator to exactly what's provided. More... | |
bool | isCapped () const final |
std::shared_ptr< CappedInsertNotifier > | getCappedInsertNotifier () const final |
Get a pointer to a capped insert notifier object. More... | |
uint64_t | numRecords (OperationContext *opCtx) const final |
uint64_t | dataSize (OperationContext *opCtx) const final |
int | averageObjectSize (OperationContext *opCtx) const |
uint64_t | getIndexSize (OperationContext *opCtx, BSONObjBuilder *details=NULL, int scale=1) final |
boost::optional< Timestamp > | getMinimumVisibleSnapshot () final |
If return value is not boost::none, reads with majority read concern using an older snapshot must error. More... | |
void | setMinimumVisibleSnapshot (Timestamp name) final |
bool | haveCappedWaiters () final |
Returns true if there may be waiters. More... | |
void | notifyCappedWaitersIfNeeded () final |
Notify (capped collection) waiters of data changes, like an insert. More... | |
const CollatorInterface * | getDefaultCollator () const final |
Get a pointer to the collection's default collator. More... | |
![]() | |
virtual | ~Impl ()=0 |
Static Public Member Functions | |
static StatusWith< ValidationLevel > | parseValidationLevel (StringData) |
static StatusWith< ValidationAction > | parseValidationAction (StringData) |
Private Member Functions | |
DatabaseCatalogEntry * | dbce () const final |
CollectionCatalogEntry * | details () const final |
Status | checkValidation (OperationContext *opCtx, const BSONObj &document) const |
Returns a non-ok Status if document does not pass this collection's validator. More... | |
Status | recordStoreGoingToUpdateInPlace (OperationContext *opCtx, const RecordId &loc) |
Status | aboutToDeleteCapped (OperationContext *opCtx, const RecordId &loc, RecordData data) |
This will be called right before loc is deleted when wrapping. More... | |
Status | _insertDocument (OperationContext *opCtx, const BSONObj &doc, bool enforceQuota) |
same semantics as insertDocument, but doesn't do: More... | |
Status | _insertDocuments (OperationContext *opCtx, std::vector< InsertStatement >::const_iterator begin, std::vector< InsertStatement >::const_iterator end, bool enforceQuota, OpDebug *opDebug) |
StatusWith< RecordId > | _updateDocumentWithMove (OperationContext *opCtx, const RecordId &oldLocation, const Snapshotted< BSONObj > &oldDoc, const BSONObj &newDoc, bool enforceQuota, OpDebug *opDebug, OplogUpdateEntryArgs *args, const SnapshotId &sid) |
Perform update when document move will be required. More... | |
bool | _enforceQuota (bool userEnforeQuota) const |
![]() | |
virtual | ~CappedCallback () |
![]() | |
virtual | ~UpdateNotifier () |
Private Attributes | |
int | _magic |
const NamespaceString | _ns |
OptionalCollectionUUID | _uuid |
CollectionCatalogEntry *const | _details |
RecordStore *const | _recordStore |
DatabaseCatalogEntry *const | _dbce |
const bool | _needCappedLock |
CollectionInfoCache | _infoCache |
IndexCatalog | _indexCatalog |
std::unique_ptr< CollatorInterface > | _collator |
BSONObj | _validatorDoc |
std::unique_ptr< MatchExpression > | _validator |
ValidationAction | _validationAction |
ValidationLevel | _validationLevel |
CursorManager | _cursorManager |
const std::shared_ptr< CappedInsertNotifier > | _cappedNotifier |
boost::optional< Timestamp > | _minVisibleSnapshot |
Collection * | _this |
Static Private Attributes | |
static const int | kMagicNumber = 1357924 |
Friends | |
class | NamespaceDetails |
|
explicit |
mongo::CollectionImpl::~CollectionImpl | ( | ) |
|
private |
|
private |
same semantics as insertDocument, but doesn't do:
|
private |
|
private |
Perform update when document move will be required.
|
privatevirtual |
This will be called right before loc is deleted when wrapping.
If data is unowned, it is only valid inside of this call. If implementations wish to stash a pointer, they must copy it.
Implements mongo::CappedCallback.
|
inline |
|
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.
inclusive | - Truncate 'end' as well iff true |
Implements mongo::Collection::Impl.
|
private |
Returns a non-ok Status if document does not pass this collection's validator.
|
finalvirtual |
Implements mongo::Collection::Impl.
|
finalvirtual |
Implements mongo::Collection::Impl.
|
inlinefinalprivatevirtual |
Implements mongo::Collection::Impl.
|
finalvirtual |
Deletes the document with the given RecordId from the collection.
'stmtId' the statement id for this delete operation. Pass in kUninitializedStmtId if not applicable. 'fromMigrate' indicates whether the delete was induced by a chunk migration, and so should be ignored by the user as an internal maintenance operation and not a real delete. 'loc' key to uniquely identify a record in a collection. 'opDebug' Optional argument. When not null, will be used to record operation statistics. 'cappedOK' if true, allows deletes on capped collections (Cloner::copyDB uses this). 'noWarn' if unindexing the record causes an error, if noWarn is true the error will not be logged. 'storeDeletedDoc' whether to store the document deleted in the oplog.
Implements mongo::Collection::Impl.
|
inlinefinalprivatevirtual |
Implements mongo::Collection::Impl.
|
inlinefinalvirtual |
Implements mongo::Collection::Impl.
|
finalvirtual |
out | - contents set to the right docs if exists, or nothing. |
Implements mongo::Collection::Impl.
|
finalvirtual |
Get a pointer to a capped insert notifier object.
The caller can wait on this object until it is notified of a new insert into the capped collection.
It is invalid to call this method unless the collection is capped.
Implements mongo::Collection::Impl.
|
inlinefinalvirtual |
Implements mongo::Collection::Impl.
|
inlinefinalvirtual |
Implements mongo::Collection::Impl.
|
finalvirtual |
Implements mongo::Collection::Impl.
|
inlinefinalvirtual |
Implements mongo::Collection::Impl.
|
finalvirtual |
Get a pointer to the collection's default collator.
The pointer must not be used after this Collection is destroyed.
Implements mongo::Collection::Impl.
|
inlinefinalvirtual |
Implements mongo::Collection::Impl.
|
inlinefinalvirtual |
Implements mongo::Collection::Impl.
|
finalvirtual |
Implements mongo::Collection::Impl.
|
finalvirtual |
Returns many cursors that partition the Collection into many disjoint sets.
Iterating all returned cursors is equivalent to iterating the full collection.
Implements mongo::Collection::Impl.
|
inlinefinalvirtual |
If return value is not boost::none, reads with majority read concern using an older snapshot must error.
Implements mongo::Collection::Impl.
|
inlinefinalvirtual |
Implements mongo::Collection::Impl.
|
inlinefinalvirtual |
Implements mongo::Collection::Impl.
|
finalvirtual |
Implements mongo::Collection::Impl.
|
finalvirtual |
Implements mongo::Collection::Impl.
|
finalvirtual |
Returns true if there may be waiters.
Implements mongo::CappedCallback.
|
inlinefinalvirtual |
Implements mongo::Collection::Impl.
|
inlinefinalvirtual |
Implements mongo::Collection::Impl.
|
finalvirtual |
Implements mongo::Collection::Impl.
|
finalvirtual |
this does NOT modify the doc before inserting i.e.
will not add an _id field for documents that are missing it
'opDebug' Optional argument. When not null, will be used to record operation statistics. 'enforceQuota' If false, quotas will be ignored.
Implements mongo::Collection::Impl.
|
finalvirtual |
Inserts a document into the record store and adds it to the MultiIndexBlocks passed in.
NOTE: It is up to caller to commit the indexes.
Implements mongo::Collection::Impl.
|
finalvirtual |
Implements mongo::Collection::Impl.
|
finalvirtual |
Callers must ensure no document validation is performed for this collection when calling this method.
Implements mongo::Collection::Impl.
|
finalvirtual |
Implements mongo::Collection::Impl.
|
finalvirtual |
Notify (capped collection) waiters of data changes, like an insert.
Implements mongo::CappedCallback.
|
inlinefinalvirtual |
Implements mongo::Collection::Impl.
|
finalvirtual |
Implements mongo::Collection::Impl.
|
inlinefinalvirtual |
Implements mongo::Collection::Impl.
|
static |
|
static |
|
finalvirtual |
Returns a non-ok Status if validator is not legal for this collection.
Implements mongo::Collection::Impl.
|
privatevirtual |
Implements mongo::UpdateNotifier.
|
finalvirtual |
Implements mongo::Collection::Impl.
|
finalvirtual |
Implements mongo::Collection::Impl.
|
inlinefinalvirtual |
Implements mongo::Collection::Impl.
|
finalvirtual |
Implements mongo::Collection::Impl.
|
finalvirtual |
Implements mongo::Collection::Impl.
|
finalvirtual |
Sets the validator for this collection.
An empty validator removes all validation. Requires an exclusive lock on the collection.
Implements mongo::Collection::Impl.
|
finalvirtual |
forces data into cache
Implements mongo::Collection::Impl.
|
finalvirtual |
removes all documents as fast as possible indexes before and after will be the same as will other characteristics
order will be: 1) store index specs 2) drop indexes 3) truncate record store 4) re-write indexes
Implements mongo::Collection::Impl.
|
finalvirtual |
Updates the document @ oldLocation with newDoc.
If the document fits in the old space, it is put there; if not, it is moved. Sets 'args.updatedDoc' to the updated version of the document with damages applied, on success. 'opDebug' Optional argument. When not null, will be used to record operation statistics.
Implements mongo::Collection::Impl.
|
finalvirtual |
Not allowed to modify indexes.
Illegal to call if updateWithDamagesSupported() returns false. Sets 'args.updatedDoc' to the updated version of the document with damages applied, on success.
Implements mongo::Collection::Impl.
|
finalvirtual |
Sets the validator to exactly what's provided.
If newLevel or newAction are empty, this sets them to the defaults. Any error Status returned by this function should be considered fatal.
Implements mongo::Collection::Impl.
|
finalvirtual |
Implements mongo::Collection::Impl.
|
inlinevirtual |
Implements mongo::Collection::Impl.
|
finalvirtual |
Implements mongo::Collection::Impl.
|
friend |
|
private |
|
private |
|
mutableprivate |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
staticprivate |