![]() |
Storage Engine API
|
Represents a logical database containing Collections. More...
#include <database_impl.h>
Represents a logical database containing Collections.
The semantics for a const Database are that you can mutate individual collections but not add or remove them.
Classes | |
class | AddCollectionChange |
class | iterator |
Iterating over a Database yields Collection* pointers. More... | |
class | RemoveCollectionChange |
Public Types | |
typedef StringMap< Collection * > | CollectionMap |
Public Member Functions | |
DatabaseImpl (Database *this_, OperationContext *opCtx, StringData name, DatabaseCatalogEntry *dbEntry) | |
~DatabaseImpl () | |
void | init (OperationContext *) final |
iterator | begin () const |
iterator | end () const |
void | close (OperationContext *opCtx, const std::string &reason) final |
const std::string & | name () const final |
void | clearTmpCollections (OperationContext *opCtx) final |
Status | setProfilingLevel (OperationContext *opCtx, int newLevel) final |
Sets a new profiling level for the database and returns the outcome. More... | |
int | getProfilingLevel () const final |
const char * | getProfilingNS () const final |
void | setDropPending (OperationContext *opCtx, bool dropPending) final |
bool | isDropPending (OperationContext *opCtx) const final |
void | getStats (OperationContext *opCtx, BSONObjBuilder *output, double scale=1) final |
const DatabaseCatalogEntry * | getDatabaseCatalogEntry () const final |
Status | dropCollection (OperationContext *opCtx, StringData fullns, repl::OpTime dropOpTime) final |
dropCollection() will refuse to drop system collections. More... | |
Status | dropCollectionEvenIfSystem (OperationContext *opCtx, const NamespaceString &fullns, repl::OpTime dropOpTime) final |
Status | dropView (OperationContext *opCtx, StringData fullns) final |
Collection * | createCollection (OperationContext *opCtx, StringData ns, const CollectionOptions &options=CollectionOptions(), bool createDefaultIndexes=true, const BSONObj &idIndex=BSONObj()) final |
Status | createView (OperationContext *opCtx, StringData viewName, const CollectionOptions &options) final |
Collection * | getCollection (OperationContext *opCtx, StringData ns) const final |
Collection * | getCollection (OperationContext *opCtx, const NamespaceString &ns) const |
ViewCatalog * | getViewCatalog () final |
Get the view catalog, which holds the definition for all views created on this database. More... | |
Collection * | getOrCreateCollection (OperationContext *opCtx, const NamespaceString &nss) final |
Status | renameCollection (OperationContext *opCtx, StringData fromNS, StringData toNS, bool stayTemp) final |
const NamespaceString & | getSystemIndexesName () const final |
const std::string & | getSystemViewsName () const final |
StatusWith< NamespaceString > | makeUniqueCollectionNamespace (OperationContext *opCtx, StringData collectionNameModel) final |
CollectionMap & | collections () final |
const CollectionMap & | collections () const final |
![]() | |
virtual | ~Impl ()=0 |
Static Public Member Functions | |
static void | dropDatabase (OperationContext *opCtx, Database *db) |
Physically drops the specified opened database and removes it from the server's metadata. More... | |
static Status | validateDBName (StringData dbname) |
Private Member Functions | |
Collection * | _getOrCreateCollectionInstance (OperationContext *opCtx, const NamespaceString &nss) |
Gets or creates collection instance from existing metadata, Returns NULL if invalid. More... | |
void | _checkCanCreateCollection (OperationContext *opCtx, const NamespaceString &nss, const CollectionOptions &options) |
Throws if there is a reason 'ns' cannot be created as a user collection. More... | |
void | _clearCollectionCache (OperationContext *opCtx, StringData fullns, const std::string &reason, bool collectionGoingAway) |
Deregisters and invalidates all cursors on collection 'fullns'. More... | |
Status | _finishDropCollection (OperationContext *opCtx, const NamespaceString &fullns, Collection *collection) |
Completes a collection drop by removing all the indexes and removing the collection itself from the storage engine. More... | |
Private Attributes | |
const std::string | _name |
DatabaseCatalogEntry * | _dbEntry |
const std::string | _profileName |
const NamespaceString | _indexesName |
const std::string | _viewsName |
int | _profile |
bool | _dropPending = false |
std::unique_ptr< PseudoRandom > | _uniqueCollectionNamespacePseudoRandom |
CollectionMap | _collections |
DurableViewCatalogImpl | _durableViews |
ViewCatalog | _views |
Database * | _this |
Friends | |
class | Collection |
class | NamespaceDetails |
class | IndexCatalog |
typedef StringMap<Collection*> mongo::DatabaseImpl::CollectionMap |
|
explicit |
mongo::DatabaseImpl::~DatabaseImpl | ( | ) |
|
private |
Throws if there is a reason 'ns' cannot be created as a user collection.
|
private |
Deregisters and invalidates all cursors on collection 'fullns'.
Callers must specify 'reason' for why the cache is being cleared. If 'collectionGoingAway' is false, unpinned cursors will not be killed.
|
private |
Completes a collection drop by removing all the indexes and removing the collection itself from the storage engine.
This is called from dropCollectionEvenIfSystem() to drop the collection immediately on unreplicated collection drops.
|
private |
Gets or creates collection instance from existing metadata, Returns NULL if invalid.
Note: This does not add the collection to _collections map, that must be done by the caller, who takes onership of the Collection*
|
inline |
|
finalvirtual |
Implements mongo::Database::Impl.
|
finalvirtual |
Implements mongo::Database::Impl.
|
inlinefinalvirtual |
Implements mongo::Database::Impl.
|
inlinefinalvirtual |
Implements mongo::Database::Impl.
|
finalvirtual |
Implements mongo::Database::Impl.
|
finalvirtual |
Implements mongo::Database::Impl.
|
finalvirtual |
dropCollection() will refuse to drop system collections.
Use dropCollectionEvenIfSystem() if that is required.
If we are applying a 'drop' oplog entry on a secondary, 'dropOpTime' will contain the optime of the oplog entry.
Implements mongo::Database::Impl.
|
finalvirtual |
Implements mongo::Database::Impl.
Physically drops the specified opened database and removes it from the server's metadata.
It doesn't notify the replication subsystem or do any other consistency checks, so it should not be used directly from user commands.
Must be called with the specified database locked in X mode.
|
finalvirtual |
Implements mongo::Database::Impl.
|
inline |
|
finalvirtual |
ns | - this is fully qualified, which is maybe not ideal ??? |
Implements mongo::Database::Impl.
Collection * mongo::DatabaseImpl::getCollection | ( | OperationContext * | opCtx, |
const NamespaceString & | ns | ||
) | const |
|
finalvirtual |
Implements mongo::Database::Impl.
|
finalvirtual |
Implements mongo::Database::Impl.
|
inlinefinalvirtual |
Implements mongo::Database::Impl.
|
inlinefinalvirtual |
Implements mongo::Database::Impl.
|
finalvirtual |
Implements mongo::Database::Impl.
|
inlinefinalvirtual |
Implements mongo::Database::Impl.
|
inlinefinalvirtual |
Implements mongo::Database::Impl.
|
inlinefinalvirtual |
Get the view catalog, which holds the definition for all views created on this database.
You must be holding a database lock to use this accessor.
Implements mongo::Database::Impl.
|
finalvirtual |
Implements mongo::Database::Impl.
|
finalvirtual |
Implements mongo::Database::Impl.
|
finalvirtual |
Implements mongo::Database::Impl.
|
inlinefinalvirtual |
Implements mongo::Database::Impl.
|
finalvirtual |
Implements mongo::Database::Impl.
|
finalvirtual |
Implements mongo::Database::Impl.
|
finalvirtual |
Sets a new profiling level for the database and returns the outcome.
opCtx | Operation context which to use for creating the profiling collection. |
newLevel | New profiling level to use. |
Implements mongo::Database::Impl.
|
static |
|
friend |
|
friend |
|
friend |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |