diff options
author | Henrik Edin <henrik.edin@mongodb.com> | 2020-08-14 10:23:04 -0400 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2020-09-02 23:53:39 +0000 |
commit | bf5914a20b596ba3bde772b42e579e028f733bac (patch) | |
tree | 2b26469571786d9adb5e95c47990c2416bfab9c4 /src/mongo/db/query/collection_query_info.cpp | |
parent | 6b3e341703b781bb1ff7b1263406a0f1d28dd77c (diff) | |
download | mongo-bf5914a20b596ba3bde772b42e579e028f733bac.tar.gz |
SERVER-50317 Const correct uses of Collection
Most of the code should only need a const Collection now. AutoGetCollection returns a const Collection by default. There is a placeholder getWritableCollection() interface that will handle the necessary steps we need for lock free reads in the future.
Added some operators to AutoGetCollection so it behaves more like a smart pointer.
Diffstat (limited to 'src/mongo/db/query/collection_query_info.cpp')
-rw-r--r-- | src/mongo/db/query/collection_query_info.cpp | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/src/mongo/db/query/collection_query_info.cpp b/src/mongo/db/query/collection_query_info.cpp index aaef235f02b..1992422d141 100644 --- a/src/mongo/db/query/collection_query_info.cpp +++ b/src/mongo/db/query/collection_query_info.cpp @@ -87,7 +87,7 @@ const UpdateIndexData& CollectionQueryInfo::getIndexKeys(OperationContext* opCtx return _indexedPaths; } -void CollectionQueryInfo::computeIndexKeys(OperationContext* opCtx, Collection* coll) { +void CollectionQueryInfo::computeIndexKeys(OperationContext* opCtx, const Collection* coll) { _indexedPaths.clear(); std::unique_ptr<IndexCatalog::IndexIterator> it = @@ -195,7 +195,8 @@ PlanCache* CollectionQueryInfo::getPlanCache() const { return _planCache.get(); } -void CollectionQueryInfo::updatePlanCacheIndexEntries(OperationContext* opCtx, Collection* coll) { +void CollectionQueryInfo::updatePlanCacheIndexEntries(OperationContext* opCtx, + const Collection* coll) { std::vector<CoreIndexInfo> indexCores; // TODO We shouldn't need to include unfinished indexes, but we must here because the index @@ -211,7 +212,7 @@ void CollectionQueryInfo::updatePlanCacheIndexEntries(OperationContext* opCtx, C _planCache->notifyOfIndexUpdates(indexCores); } -void CollectionQueryInfo::init(OperationContext* opCtx, Collection* coll) { +void CollectionQueryInfo::init(OperationContext* opCtx, const Collection* coll) { const bool includeUnfinishedIndexes = false; std::unique_ptr<IndexCatalog::IndexIterator> ii = coll->getIndexCatalog()->getIndexIterator(opCtx, includeUnfinishedIndexes); @@ -225,7 +226,7 @@ void CollectionQueryInfo::init(OperationContext* opCtx, Collection* coll) { } void CollectionQueryInfo::addedIndex(OperationContext* opCtx, - Collection* coll, + const Collection* coll, const IndexDescriptor* desc) { invariant(desc); @@ -235,14 +236,14 @@ void CollectionQueryInfo::addedIndex(OperationContext* opCtx, } void CollectionQueryInfo::droppedIndex(OperationContext* opCtx, - Collection* coll, + const Collection* coll, StringData indexName) { rebuildIndexData(opCtx, coll); CollectionIndexUsageTrackerDecoration::get(coll->getSharedDecorations()) .unregisterIndex(indexName); } -void CollectionQueryInfo::rebuildIndexData(OperationContext* opCtx, Collection* coll) { +void CollectionQueryInfo::rebuildIndexData(OperationContext* opCtx, const Collection* coll) { clearQueryCache(coll); _keysComputed = false; |