From 2173ffb9fd23c6894c6820fbf8c08aa876392b55 Mon Sep 17 00:00:00 2001 From: Gregory Wlodarek Date: Wed, 9 Aug 2017 22:40:50 -0400 Subject: SERVER-30353 Create an index observer to notify us of changes made to index and document keys --- src/mongo/db/catalog/collection_impl.h | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'src/mongo/db/catalog/collection_impl.h') diff --git a/src/mongo/db/catalog/collection_impl.h b/src/mongo/db/catalog/collection_impl.h index 4a766faa9aa..1fdfc40d1fa 100644 --- a/src/mongo/db/catalog/collection_impl.h +++ b/src/mongo/db/catalog/collection_impl.h @@ -30,8 +30,12 @@ #include "mongo/db/catalog/collection.h" #include "mongo/db/catalog/collection_catalog_entry.h" +#include "mongo/db/catalog/index_catalog.h" +#include "mongo/db/concurrency/d_concurrency.h" namespace mongo { +class IndexConsistency; +class IndexObserver; class UUIDCatalog; class CollectionImpl final : virtual public Collection::Impl, virtual CappedCallback, @@ -349,6 +353,15 @@ public: */ const CollatorInterface* getDefaultCollator() const final; + /** + * Calls the Inform function in the IndexObserver if it's hooked. + */ + void informIndexObserver(OperationContext* opCtx, + const IndexDescriptor* descriptor, + const IndexKeyEntry& indexEntry, + const ValidationOperation operation) const; + + private: inline DatabaseCatalogEntry* dbce() const final { return this->_dbce; @@ -358,6 +371,16 @@ private: return this->_details; } + /** + * Hooks the IndexObserver into the collection. + */ + void hookIndexObserver(IndexConsistency* consistency); + + /** + * Unhooks the IndexObserver from the collection. + */ + void unhookIndexObserver(); + /** * Returns a non-ok Status if document does not pass this collection's validator. */ @@ -406,6 +429,9 @@ private: CollectionInfoCache _infoCache; IndexCatalog _indexCatalog; + mutable stdx::mutex _indexObserverMutex; + mutable std::unique_ptr _indexObserver; + // The default collation which is applied to operations and indices which have no collation of // their own. The collection's validator will respect this collation. // -- cgit v1.2.1