![]() |
Storage Engine API
|
how many: 1 per Collection. More...
#include <index_catalog_impl.h>
how many: 1 per Collection.
lifecycle: attached to a Collection.
Classes | |
class | IndexBuildBlock |
disk creation order 1) system.indexes entry 2) collection's NamespaceDetails a) info + head b) _indexBuildsInProgress++ 3) indexes entry in .ns file 4) system.namespaces entry for index ns More... | |
class | IndexIteratorImpl |
struct | IndexKillCriteria |
Public Types | |
using | IndexIterator = IndexCatalog::IndexIterator |
Public Member Functions | |
IndexCatalogImpl (IndexCatalog *this_, Collection *collection, int maxNumIndexesAllowed) | |
~IndexCatalogImpl () override | |
Status | init (OperationContext *opCtx) override |
bool | ok () const override |
bool | haveAnyIndexes () const override |
int | numIndexesTotal (OperationContext *opCtx) const override |
int | numIndexesReady (OperationContext *opCtx) const override |
int | numIndexesInProgress (OperationContext *opCtx) const |
bool | haveIdIndex (OperationContext *opCtx) const override |
this is in "alive" until the Collection goes away in which case everything from this tree has to go away. More... | |
BSONObj | getDefaultIdIndexSpec () const override |
Returns the spec for the id index to create by default for this collection. More... | |
IndexDescriptor * | findIdIndex (OperationContext *opCtx) const override |
IndexDescriptor * | findIndexByName (OperationContext *opCtx, StringData name, bool includeUnfinishedIndexes=false) const override |
Find index by name. More... | |
IndexDescriptor * | findIndexByKeyPatternAndCollationSpec (OperationContext *opCtx, const BSONObj &key, const BSONObj &collationSpec, bool includeUnfinishedIndexes=false) const override |
Find index by matching key pattern and collation spec. More... | |
void | findIndexesByKeyPattern (OperationContext *opCtx, const BSONObj &key, bool includeUnfinishedIndexes, std::vector< IndexDescriptor *> *matches) const override |
Find indexes with a matching key pattern, putting them into the vector 'matches'. More... | |
IndexDescriptor * | findShardKeyPrefixedIndex (OperationContext *opCtx, const BSONObj &shardKey, bool requireSingleKey) const override |
Returns an index suitable for shard key range scans. More... | |
void | findIndexByType (OperationContext *opCtx, const std::string &type, std::vector< IndexDescriptor *> &matches, bool includeUnfinishedIndexes=false) const override |
const IndexDescriptor * | refreshEntry (OperationContext *opCtx, const IndexDescriptor *oldDesc) override |
Reload the index definition for 'oldDesc' from the CollectionCatalogEntry. More... | |
const IndexCatalogEntry * | getEntry (const IndexDescriptor *desc) const override |
IndexAccessMethod * | getIndex (const IndexDescriptor *desc) override |
const IndexAccessMethod * | getIndex (const IndexDescriptor *desc) const override |
Status | checkUnfinished () const override |
Returns a not-ok Status if there are any unfinished index builds. More... | |
StatusWith< BSONObj > | createIndexOnEmptyCollection (OperationContext *opCtx, BSONObj spec) override |
Call this only on an empty collection from inside a WriteUnitOfWork. More... | |
StatusWith< BSONObj > | prepareSpecForCreate (OperationContext *opCtx, const BSONObj &original) const override |
void | dropAllIndexes (OperationContext *opCtx, bool includingIdIndex, stdx::function< void(const IndexDescriptor *)> onDropFn=nullptr) override |
Drops all indexes in the index catalog, optionally dropping the id index depending on the 'includingIdIndex' parameter value. More... | |
Status | dropIndex (OperationContext *opCtx, IndexDescriptor *desc) override |
std::vector< BSONObj > | getAndClearUnfinishedIndexes (OperationContext *opCtx) override |
will drop all incompleted indexes and return specs after this, the indexes can be rebuilt More... | |
bool | isMultikey (OperationContext *opCtx, const IndexDescriptor *idx) override |
Returns true if the index 'idx' is multikey, and returns false otherwise. More... | |
MultikeyPaths | getMultikeyPaths (OperationContext *opCtx, const IndexDescriptor *idx) override |
Returns the path components that cause the index 'idx' to be multikey if the index supports path-level multikey tracking, and returns an empty vector if path-level multikey tracking isn't supported. More... | |
Status | indexRecords (OperationContext *opCtx, const std::vector< BsonRecord > &bsonRecords, int64_t *keysInsertedOut) override |
When 'keysInsertedOut' is not null, it will be set to the number of index keys inserted by this operation. More... | |
void | unindexRecord (OperationContext *opCtx, const BSONObj &obj, const RecordId &loc, bool noWarn, int64_t *keysDeletedOut) override |
When 'keysDeletedOut' is not null, it will be set to the number of index keys removed by this operation. More... | |
std::string | getAccessMethodName (OperationContext *opCtx, const BSONObj &keyPattern) override |
Status | _upgradeDatabaseMinorVersionIfNeeded (OperationContext *opCtx, const std::string &newPluginName) override |
![]() | |
virtual | ~Impl ()=0 |
Static Public Member Functions | |
static BSONObj | fixIndexKey (const BSONObj &key) |
static void | prepareInsertDeleteOptions (OperationContext *opCtx, const IndexDescriptor *desc, InsertDeleteOptions *options) |
Fills out 'options' in order to indicate whether to allow dups or relax index constraints, as needed by replication. More... | |
Private Member Functions | |
bool | _shouldOverridePlugin (OperationContext *opCtx, const BSONObj &keyPattern) const |
std::string | _getAccessMethodName (OperationContext *opCtx, const BSONObj &keyPattern) const |
This differs from IndexNames::findPluginName in that returns the plugin name we should use, not the plugin name inside of the provided key pattern. More... | |
void | _checkMagic () const |
Status | _indexFilteredRecords (OperationContext *opCtx, IndexCatalogEntry *index, const std::vector< BsonRecord > &bsonRecords, int64_t *keysInsertedOut) |
Status | _indexRecords (OperationContext *opCtx, IndexCatalogEntry *index, const std::vector< BsonRecord > &bsonRecords, int64_t *keysInsertedOut) |
Status | _unindexRecord (OperationContext *opCtx, IndexCatalogEntry *index, const BSONObj &obj, const RecordId &loc, bool logIfError, int64_t *keysDeletedOut) |
const IndexCatalogEntryContainer & | _getEntries () const override |
IndexCatalogEntryContainer & | _getEntries () override |
Status | _dropIndex (OperationContext *opCtx, IndexCatalogEntry *entry) override |
this does no sanity checks More... | |
void | _deleteIndexFromDisk (OperationContext *opCtx, const std::string &indexName, const std::string &indexNamespace) |
IndexCatalogEntry * | _setupInMemoryStructures (OperationContext *opCtx, std::unique_ptr< IndexDescriptor > descriptor, bool initFromDisk) |
Status | _isSpecOk (OperationContext *opCtx, const BSONObj &spec) const |
Status | _doesSpecConflictWithExisting (OperationContext *opCtx, const BSONObj &spec) const |
const Collection * | _getCollection () const override |
Collection * | _getCollection () override |
Static Private Member Functions | |
static StatusWith< BSONObj > | _fixIndexSpec (OperationContext *opCtx, Collection *collection, const BSONObj &spec) |
static IndexCatalogEntry * | _setupInMemoryStructures (IndexCatalog *const this_, OperationContext *const opCtx, std::unique_ptr< IndexDescriptor > descriptor, const bool initFromDisk) |
static Status | _dropIndex (IndexCatalog *const this_, OperationContext *const opCtx, IndexCatalogEntry *const desc) |
Private Attributes | |
int | _magic |
Collection *const | _collection |
const int | _maxNumIndexesAllowed |
IndexCatalogEntryContainer | _entries |
std::vector< BSONObj > | _unfinishedIndexes |
IndexCatalog *const | _this |
Static Private Attributes | |
static const BSONObj | _idObj = BSON("_id" << 1) |
|
explicit |
|
override |
|
private |
|
privatevirtual |
Implements mongo::IndexCatalog::Impl.
|
private |
|
overrideprivatevirtual |
this does no sanity checks
IndexState in order <db>.system.indexes NamespaceDetails <db>.system.ns
Implements mongo::IndexCatalog::Impl.
|
inlinestaticprivate |
|
staticprivate |
|
private |
This differs from IndexNames::findPluginName in that returns the plugin name we should use, not the plugin name inside of the provided key pattern.
To understand when these differ, see shouldOverridePlugin.
|
inlineoverrideprivatevirtual |
Implements mongo::IndexCatalog::Impl.
|
inlineoverrideprivatevirtual |
Implements mongo::IndexCatalog::Impl.
|
inlineoverrideprivatevirtual |
Implements mongo::IndexCatalog::Impl.
|
inlineoverrideprivatevirtual |
Implements mongo::IndexCatalog::Impl.
|
private |
|
private |
|
private |
|
privatevirtual |
Implements mongo::IndexCatalog::Impl.
|
inlinestaticprivate |
|
private |
|
private |
|
overridevirtual |
Implements mongo::IndexCatalog::Impl.
|
overridevirtual |
Returns a not-ok Status if there are any unfinished index builds.
No new indexes should be built when in this state.
Implements mongo::IndexCatalog::Impl.
|
overridevirtual |
Call this only on an empty collection from inside a WriteUnitOfWork.
Index creation on an empty collection can be rolled back as part of a larger WUOW. Returns the full specification of the created index, as it is stored in this index catalog.
Implements mongo::IndexCatalog::Impl.
|
overridevirtual |
Drops all indexes in the index catalog, optionally dropping the id index depending on the 'includingIdIndex' parameter value.
If the 'droppedIndexes' parameter is not null, it is filled with the names and index info of the dropped indexes.
Implements mongo::IndexCatalog::Impl.
|
overridevirtual |
Implements mongo::IndexCatalog::Impl.
|
overridevirtual |
Implements mongo::IndexCatalog::Impl.
|
overridevirtual |
Find index by matching key pattern and collation spec.
The key pattern and collation spec uniquely identify an index.
Collation is specified as a normalized collation spec as returned by CollationInterface::getSpec. An empty object indicates the simple collation.
Implements mongo::IndexCatalog::Impl.
|
overridevirtual |
Find index by name.
The index name uniquely identifies an index.
Implements mongo::IndexCatalog::Impl.
|
overridevirtual |
Implements mongo::IndexCatalog::Impl.
|
overridevirtual |
Find indexes with a matching key pattern, putting them into the vector 'matches'.
The key pattern alone does not uniquely identify an index.
Consider using 'findIndexByName' if expecting to match one index.
Implements mongo::IndexCatalog::Impl.
|
overridevirtual |
Returns an index suitable for shard key range scans.
This index:
If the parameter 'requireSingleKey' is true, then this index additionally must not be multi-key.
If no such index exists, returns NULL.
Implements mongo::IndexCatalog::Impl.
|
static |
|
inlineoverridevirtual |
Implements mongo::IndexCatalog::Impl.
|
overridevirtual |
will drop all incompleted indexes and return specs after this, the indexes can be rebuilt
Implements mongo::IndexCatalog::Impl.
|
overridevirtual |
Returns the spec for the id index to create by default for this collection.
Implements mongo::IndexCatalog::Impl.
|
overridevirtual |
Implements mongo::IndexCatalog::Impl.
|
overridevirtual |
Implements mongo::IndexCatalog::Impl.
|
overridevirtual |
Implements mongo::IndexCatalog::Impl.
|
overridevirtual |
Returns the path components that cause the index 'idx' to be multikey if the index supports path-level multikey tracking, and returns an empty vector if path-level multikey tracking isn't supported.
If the index supports path-level multikey tracking but isn't multikey, then this function returns a vector with size equal to the number of elements in the index key pattern where each element in the vector is an empty set.
Implements mongo::IndexCatalog::Impl.
|
overridevirtual |
Implements mongo::IndexCatalog::Impl.
|
overridevirtual |
this is in "alive" until the Collection goes away in which case everything from this tree has to go away.
Implements mongo::IndexCatalog::Impl.
|
overridevirtual |
When 'keysInsertedOut' is not null, it will be set to the number of index keys inserted by this operation.
This method may throw.
Implements mongo::IndexCatalog::Impl.
|
overridevirtual |
Implements mongo::IndexCatalog::Impl.
|
overridevirtual |
Returns true if the index 'idx' is multikey, and returns false otherwise.
Implements mongo::IndexCatalog::Impl.
|
inline |
|
overridevirtual |
Implements mongo::IndexCatalog::Impl.
|
overridevirtual |
Implements mongo::IndexCatalog::Impl.
|
overridevirtual |
Implements mongo::IndexCatalog::Impl.
|
static |
Fills out 'options' in order to indicate whether to allow dups or relax index constraints, as needed by replication.
|
overridevirtual |
Implements mongo::IndexCatalog::Impl.
|
overridevirtual |
Reload the index definition for 'oldDesc' from the CollectionCatalogEntry.
'oldDesc' must be a ready index that is already registered with the index catalog. Returns an unowned pointer to the descriptor for the new index definition.
Use this method to notify the IndexCatalog that the spec for this index has changed.
It is invalid to dereference 'oldDesc' after calling this method. This method broadcasts an invalidateAll() on the cursor manager to notify other users of the IndexCatalog that this descriptor is now invalid.
Implements mongo::IndexCatalog::Impl.
|
overridevirtual |
When 'keysDeletedOut' is not null, it will be set to the number of index keys removed by this operation.
Implements mongo::IndexCatalog::Impl.
|
private |
|
private |
|
staticprivate |
|
private |
|
private |
|
private |
|
private |