diff options
Diffstat (limited to 'src/mongo/db/catalog/collection_info_cache_impl.cpp')
-rw-r--r-- | src/mongo/db/catalog/collection_info_cache_impl.cpp | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/src/mongo/db/catalog/collection_info_cache_impl.cpp b/src/mongo/db/catalog/collection_info_cache_impl.cpp index 9223cba45b8..55a1d838642 100644 --- a/src/mongo/db/catalog/collection_info_cache_impl.cpp +++ b/src/mongo/db/catalog/collection_info_cache_impl.cpp @@ -88,14 +88,16 @@ void CollectionInfoCacheImpl::computeIndexKeys(OperationContext* opCtx) { bool hadTTLIndex = _hasTTLIndex; _hasTTLIndex = false; - IndexCatalog::IndexIterator i = _collection->getIndexCatalog()->getIndexIterator(opCtx, true); - while (i.more()) { - IndexDescriptor* descriptor = i.next(); + std::unique_ptr<IndexCatalog::IndexIterator> it = + _collection->getIndexCatalog()->getIndexIterator(opCtx, true); + while (it->more()) { + IndexCatalogEntry* entry = it->next(); + IndexDescriptor* descriptor = entry->descriptor(); + IndexAccessMethod* iam = entry->accessMethod(); if (descriptor->getAccessMethodName() == IndexNames::WILDCARD) { // Obtain the projection used by the $** index's key generator. - const auto* pathProj = - static_cast<WildcardAccessMethod*>(i.accessMethod(descriptor))->getProjectionExec(); + const auto* pathProj = static_cast<WildcardAccessMethod*>(iam)->getProjectionExec(); // If the projection is an exclusion, then we must check the new document's keys on all // updates, since we do not exhaustively know the set of paths to be indexed. if (pathProj->getType() == ProjectionExecAgg::ProjectionType::kExclusionProjection) { @@ -142,7 +144,6 @@ void CollectionInfoCacheImpl::computeIndexKeys(OperationContext* opCtx) { } // handle partial indexes - const IndexCatalogEntry* entry = i.catalogEntry(descriptor); const MatchExpression* filter = entry->getFilterExpression(); if (filter) { stdx::unordered_set<std::string> paths; @@ -199,11 +200,10 @@ void CollectionInfoCacheImpl::updatePlanCacheIndexEntries(OperationContext* opCt // TODO We shouldn't need to include unfinished indexes, but we must here because the index // catalog may be in an inconsistent state. SERVER-18346. const bool includeUnfinishedIndexes = true; - IndexCatalog::IndexIterator ii = + std::unique_ptr<IndexCatalog::IndexIterator> ii = _collection->getIndexCatalog()->getIndexIterator(opCtx, includeUnfinishedIndexes); - while (ii.more()) { - const IndexDescriptor* desc = ii.next(); - const IndexCatalogEntry* ice = ii.catalogEntry(desc); + while (ii->more()) { + const IndexCatalogEntry* ice = ii->next(); indexEntries.emplace_back(indexEntryFromIndexCatalogEntry(opCtx, *ice)); } @@ -215,10 +215,10 @@ void CollectionInfoCacheImpl::init(OperationContext* opCtx) { invariant(opCtx->lockState()->isCollectionLockedForMode(_collection->ns().ns(), MODE_X)); const bool includeUnfinishedIndexes = false; - IndexCatalog::IndexIterator ii = + std::unique_ptr<IndexCatalog::IndexIterator> ii = _collection->getIndexCatalog()->getIndexIterator(opCtx, includeUnfinishedIndexes); - while (ii.more()) { - const IndexDescriptor* desc = ii.next(); + while (ii->more()) { + const IndexDescriptor* desc = ii->next()->descriptor(); _indexUsageTracker.registerIndex(desc->indexName(), desc->keyPattern()); } |