summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBenety Goh <benety@mongodb.com>2018-10-12 06:03:01 -0400
committerBenety Goh <benety@mongodb.com>2018-10-12 06:03:15 -0400
commit849c85561e065598813d6a702ce132f494380eed (patch)
tree7467d8bbc8f877585918242799043b3cdbad0f63 /src
parent6ac6f0efe6e2b6452f2238beb765396f983c53cb (diff)
downloadmongo-849c85561e065598813d6a702ce132f494380eed.tar.gz
SERVER-36889 unshim IndexCatalogEntry
Diffstat (limited to 'src')
-rw-r--r--src/mongo/db/catalog/index_catalog_entry.cpp25
-rw-r--r--src/mongo/db/catalog/index_catalog_entry.h188
-rw-r--r--src/mongo/db/catalog/index_catalog_entry_impl.cpp19
-rw-r--r--src/mongo/db/catalog/index_catalog_entry_impl.h3
-rw-r--r--src/mongo/db/catalog/index_catalog_impl.cpp11
-rw-r--r--src/mongo/db/catalog/index_create.h1
6 files changed, 39 insertions, 208 deletions
diff --git a/src/mongo/db/catalog/index_catalog_entry.cpp b/src/mongo/db/catalog/index_catalog_entry.cpp
index 1972c2237d4..3922d2571be 100644
--- a/src/mongo/db/catalog/index_catalog_entry.cpp
+++ b/src/mongo/db/catalog/index_catalog_entry.cpp
@@ -36,30 +36,6 @@
#include "mongo/db/index/index_descriptor.h"
namespace mongo {
-IndexCatalogEntry::Impl::~Impl() = default;
-
-MONGO_DEFINE_SHIM(IndexCatalogEntry::makeImpl);
-
-void IndexCatalogEntry::TUHook::hook() noexcept {}
-
-IndexCatalogEntry::IndexCatalogEntry(OperationContext* opCtx,
- StringData ns,
- CollectionCatalogEntry* collection,
- std::unique_ptr<IndexDescriptor> descriptor,
- CollectionInfoCache* infoCache)
- : _pimpl(makeImpl(this,
- opCtx,
- ns,
- collection,
- std::move(descriptor),
- infoCache,
- PrivateCall<IndexCatalogEntry>{})) {}
-
-void IndexCatalogEntry::init(std::unique_ptr<IndexAccessMethod> accessMethod) {
- return this->_impl().init(std::move(accessMethod));
-}
-
-// ------------------
const IndexCatalogEntry* IndexCatalogEntryContainer::find(const IndexDescriptor* desc) const {
if (desc->_cachedEntry)
@@ -104,4 +80,5 @@ IndexCatalogEntry* IndexCatalogEntryContainer::release(const IndexDescriptor* de
}
return nullptr;
}
+
} // namespace mongo
diff --git a/src/mongo/db/catalog/index_catalog_entry.h b/src/mongo/db/catalog/index_catalog_entry.h
index 98f7554b058..67edd00b3c3 100644
--- a/src/mongo/db/catalog/index_catalog_entry.h
+++ b/src/mongo/db/catalog/index_catalog_entry.h
@@ -32,7 +32,6 @@
#include <string>
#include "mongo/base/owned_pointer_vector.h"
-#include "mongo/base/shim.h"
#include "mongo/bson/ordering.h"
#include "mongo/bson/timestamp.h"
#include "mongo/db/index/multikey_paths.h"
@@ -55,144 +54,46 @@ class OperationContext;
class IndexCatalogEntry {
public:
- // This class represents the internal vtable for the (potentially polymorphic) implementation of
- // the `IndexCatalogEntry` class. This allows us to expose an interface to this object without
- // requiring a dependency upon the implementation's definition library.
- class Impl {
- public:
- virtual ~Impl() = 0;
-
- virtual const std::string& ns() const = 0;
-
- virtual void init(std::unique_ptr<IndexAccessMethod> accessMethod) = 0;
-
- virtual IndexDescriptor* descriptor() = 0;
-
- virtual const IndexDescriptor* descriptor() const = 0;
-
- virtual IndexAccessMethod* accessMethod() = 0;
-
- virtual const IndexAccessMethod* accessMethod() const = 0;
-
- virtual const Ordering& ordering() const = 0;
-
- virtual const MatchExpression* getFilterExpression() const = 0;
-
- virtual const CollatorInterface* getCollator() const = 0;
-
- virtual const RecordId& head(OperationContext* opCtx) const = 0;
-
- virtual void setHead(OperationContext* opCtx, RecordId newHead) = 0;
-
- virtual void setIsReady(bool newIsReady) = 0;
-
- virtual HeadManager* headManager() const = 0;
-
- virtual bool isMultikey(OperationContext* opCtx) const = 0;
-
- virtual MultikeyPaths getMultikeyPaths(OperationContext* opCtx) const = 0;
-
- virtual void setMultikey(OperationContext* opCtx, const MultikeyPaths& multikeyPaths) = 0;
-
- // TODO SERVER-36385 Remove this function: we don't set the feature tracker bit in 4.4
- // because 4.4 can only downgrade to 4.2 which can read long TypeBits.
- virtual void setIndexKeyStringWithLongTypeBitsExistsOnDisk(OperationContext* opCtx) = 0;
-
- virtual bool isReady(OperationContext* opCtx) const = 0;
-
- virtual KVPrefix getPrefix() const = 0;
-
- virtual boost::optional<Timestamp> getMinimumVisibleSnapshot() = 0;
-
- virtual void setMinimumVisibleSnapshot(Timestamp name) = 0;
- };
-
-public:
- static MONGO_DECLARE_SHIM((IndexCatalogEntry * this_,
- OperationContext* opCtx,
- StringData ns,
- CollectionCatalogEntry* collection,
- std::unique_ptr<IndexDescriptor> descriptor,
- CollectionInfoCache* infoCache,
- PrivateTo<IndexCatalogEntry>)
- ->std::unique_ptr<Impl>) makeImpl;
-
- explicit IndexCatalogEntry(
- OperationContext* opCtx,
- StringData ns,
- CollectionCatalogEntry* collection, // not owned
- std::unique_ptr<IndexDescriptor> descriptor, // ownership passes to me
- CollectionInfoCache* infoCache); // not owned, optional
-
- // Do not call this function. It exists for use with test drivers that need to inject
- // alternative implementations.
- explicit IndexCatalogEntry(std::unique_ptr<Impl> impl) : _pimpl(std::move(impl)) {}
-
- inline ~IndexCatalogEntry() = default;
+ IndexCatalogEntry() = default;
+ virtual ~IndexCatalogEntry() = default;
inline IndexCatalogEntry(IndexCatalogEntry&&) = delete;
inline IndexCatalogEntry& operator=(IndexCatalogEntry&&) = delete;
- inline const std::string& ns() const {
- return this->_impl().ns();
- }
+ virtual const std::string& ns() const = 0;
- void init(std::unique_ptr<IndexAccessMethod> accessMethod);
+ virtual void init(std::unique_ptr<IndexAccessMethod> accessMethod) = 0;
- inline IndexDescriptor* descriptor() {
- return this->_impl().descriptor();
- }
+ virtual IndexDescriptor* descriptor() = 0;
- inline const IndexDescriptor* descriptor() const {
- return this->_impl().descriptor();
- }
+ virtual const IndexDescriptor* descriptor() const = 0;
- inline IndexAccessMethod* accessMethod() {
- return this->_impl().accessMethod();
- }
+ virtual IndexAccessMethod* accessMethod() = 0;
- inline const IndexAccessMethod* accessMethod() const {
- return this->_impl().accessMethod();
- }
+ virtual const IndexAccessMethod* accessMethod() const = 0;
- inline const Ordering& ordering() const {
- return this->_impl().ordering();
- }
+ virtual const Ordering& ordering() const = 0;
- inline const MatchExpression* getFilterExpression() const {
- return this->_impl().getFilterExpression();
- }
+ virtual const MatchExpression* getFilterExpression() const = 0;
- inline const CollatorInterface* getCollator() const {
- return this->_impl().getCollator();
- }
+ virtual const CollatorInterface* getCollator() const = 0;
/// ---------------------
- inline const RecordId& head(OperationContext* const opCtx) const {
- return this->_impl().head(opCtx);
- }
+ virtual const RecordId& head(OperationContext* const opCtx) const = 0;
- inline void setHead(OperationContext* const opCtx, const RecordId newHead) {
- return this->_impl().setHead(opCtx, newHead);
- }
+ virtual void setHead(OperationContext* const opCtx, const RecordId newHead) = 0;
- inline void setIsReady(const bool newIsReady) {
- return this->_impl().setIsReady(newIsReady);
- }
+ virtual void setIsReady(const bool newIsReady) = 0;
- inline HeadManager* headManager() const {
- return this->_impl().headManager();
- }
+ virtual HeadManager* headManager() const = 0;
// --
/**
* Returns true if this index is multikey and false otherwise.
*/
- inline bool isMultikey(OperationContext* opCtx) const {
- return this->_impl().isMultikey(opCtx);
- }
+ virtual bool isMultikey(OperationContext* opCtx) const = 0;
/**
* Returns the path components that cause this index to be multikey if this index supports
@@ -203,9 +104,7 @@ public:
* 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.
*/
- inline MultikeyPaths getMultikeyPaths(OperationContext* const opCtx) const {
- return this->_impl().getMultikeyPaths(opCtx);
- }
+ virtual MultikeyPaths getMultikeyPaths(OperationContext* const opCtx) const = 0;
/**
* Sets this index to be multikey. Information regarding which newly detected path components
@@ -222,59 +121,26 @@ public:
* namespace, index name, and multikey paths on the OperationContext rather than set the index
* as multikey here.
*/
- void setMultikey(OperationContext* const opCtx, const MultikeyPaths& multikeyPaths) {
- return this->_impl().setMultikey(opCtx, multikeyPaths);
- }
+ virtual void setMultikey(OperationContext* const opCtx, const MultikeyPaths& multikeyPaths) = 0;
- void setIndexKeyStringWithLongTypeBitsExistsOnDisk(OperationContext* const opCtx) {
- return this->_impl().setIndexKeyStringWithLongTypeBitsExistsOnDisk(opCtx);
- }
+ /**
+ * TODO SERVER-36385 Remove this function: we don't set the feature tracker bit in 4.4
+ * because 4.4 can only downgrade to 4.2 which can read long TypeBits.
+ */
+ virtual void setIndexKeyStringWithLongTypeBitsExistsOnDisk(OperationContext* const opCtx) = 0;
// if this ready is ready for queries
- bool isReady(OperationContext* const opCtx) const {
- return this->_impl().isReady(opCtx);
- }
+ virtual bool isReady(OperationContext* const opCtx) const = 0;
- KVPrefix getPrefix() const {
- return this->_impl().getPrefix();
- }
+ virtual KVPrefix getPrefix() const = 0;
/**
* If return value is not boost::none, reads with majority read concern using an older snapshot
* must treat this index as unfinished.
*/
- boost::optional<Timestamp> getMinimumVisibleSnapshot() {
- return this->_impl().getMinimumVisibleSnapshot();
- }
-
- void setMinimumVisibleSnapshot(const Timestamp name) {
- return this->_impl().setMinimumVisibleSnapshot(name);
- }
-
-private:
- // This structure exists to give us a customization point to decide how to force users of this
- // class to depend upon the corresponding `index_catalog_entry.cpp` Translation Unit (TU). All
- // public forwarding functions call `_impl(), and `_impl` creates an instance of this structure.
- struct TUHook {
- static void hook() noexcept;
-
- explicit inline TUHook() noexcept {
- if (kDebugBuild)
- this->hook();
- }
- };
-
- inline const Impl& _impl() const {
- TUHook{};
- return *this->_pimpl;
- }
-
- inline Impl& _impl() {
- TUHook{};
- return *this->_pimpl;
- }
+ virtual boost::optional<Timestamp> getMinimumVisibleSnapshot() = 0;
- std::unique_ptr<Impl> _pimpl;
+ virtual void setMinimumVisibleSnapshot(const Timestamp name) = 0;
};
class IndexCatalogEntryContainer {
diff --git a/src/mongo/db/catalog/index_catalog_entry_impl.cpp b/src/mongo/db/catalog/index_catalog_entry_impl.cpp
index 9d24c7c7c08..a4d810a85d6 100644
--- a/src/mongo/db/catalog/index_catalog_entry_impl.cpp
+++ b/src/mongo/db/catalog/index_catalog_entry_impl.cpp
@@ -54,18 +54,6 @@
#include "mongo/util/scopeguard.h"
namespace mongo {
-MONGO_REGISTER_SHIM(IndexCatalogEntry::makeImpl)
-(IndexCatalogEntry* const this_,
- OperationContext* const opCtx,
- const StringData ns,
- CollectionCatalogEntry* const collection,
- std::unique_ptr<IndexDescriptor> descriptor,
- CollectionInfoCache* const infoCache,
- PrivateTo<IndexCatalogEntry>)
- ->std::unique_ptr<IndexCatalogEntry::Impl> {
- return std::make_unique<IndexCatalogEntryImpl>(
- this_, opCtx, ns, collection, std::move(descriptor), infoCache);
-}
using std::string;
@@ -87,8 +75,7 @@ private:
IndexCatalogEntry* _catalogEntry;
};
-IndexCatalogEntryImpl::IndexCatalogEntryImpl(IndexCatalogEntry* const this_,
- OperationContext* const opCtx,
+IndexCatalogEntryImpl::IndexCatalogEntryImpl(OperationContext* const opCtx,
const StringData ns,
CollectionCatalogEntry* const collection,
std::unique_ptr<IndexDescriptor> descriptor,
@@ -97,11 +84,11 @@ IndexCatalogEntryImpl::IndexCatalogEntryImpl(IndexCatalogEntry* const this_,
_collection(collection),
_descriptor(std::move(descriptor)),
_infoCache(infoCache),
- _headManager(stdx::make_unique<HeadManagerImpl>(this_)),
+ _headManager(stdx::make_unique<HeadManagerImpl>(this)),
_ordering(Ordering::make(_descriptor->keyPattern())),
_isReady(false),
_prefix(collection->getIndexPrefix(opCtx, _descriptor->indexName())) {
- _descriptor->_cachedEntry = this_;
+ _descriptor->_cachedEntry = this;
_isReady = _catalogIsReady(opCtx);
_head = _catalogHead(opCtx);
diff --git a/src/mongo/db/catalog/index_catalog_entry_impl.h b/src/mongo/db/catalog/index_catalog_entry_impl.h
index e663d67c051..b949e589e5f 100644
--- a/src/mongo/db/catalog/index_catalog_entry_impl.h
+++ b/src/mongo/db/catalog/index_catalog_entry_impl.h
@@ -53,12 +53,11 @@ class IndexDescriptor;
class MatchExpression;
class OperationContext;
-class IndexCatalogEntryImpl : public IndexCatalogEntry::Impl {
+class IndexCatalogEntryImpl : public IndexCatalogEntry {
MONGO_DISALLOW_COPYING(IndexCatalogEntryImpl);
public:
explicit IndexCatalogEntryImpl(
- IndexCatalogEntry* this_,
OperationContext* opCtx,
StringData ns,
CollectionCatalogEntry* collection, // not owned
diff --git a/src/mongo/db/catalog/index_catalog_impl.cpp b/src/mongo/db/catalog/index_catalog_impl.cpp
index 16323385052..3539a9d08b0 100644
--- a/src/mongo/db/catalog/index_catalog_impl.cpp
+++ b/src/mongo/db/catalog/index_catalog_impl.cpp
@@ -42,6 +42,7 @@
#include "mongo/db/catalog/collection.h"
#include "mongo/db/catalog/collection_catalog_entry.h"
#include "mongo/db/catalog/database_catalog_entry.h"
+#include "mongo/db/catalog/index_catalog_entry_impl.h"
#include "mongo/db/catalog/index_create.h"
#include "mongo/db/catalog/index_key_validate.h"
#include "mongo/db/client.h"
@@ -143,11 +144,11 @@ IndexCatalogEntry* IndexCatalogImpl::_setupInMemoryStructures(
}
auto* const descriptorPtr = descriptor.get();
- auto entry = stdx::make_unique<IndexCatalogEntry>(opCtx,
- _collection->ns().ns(),
- _collection->getCatalogEntry(),
- std::move(descriptor),
- _collection->infoCache());
+ auto entry = stdx::make_unique<IndexCatalogEntryImpl>(opCtx,
+ _collection->ns().ns(),
+ _collection->getCatalogEntry(),
+ std::move(descriptor),
+ _collection->infoCache());
std::unique_ptr<IndexAccessMethod> accessMethod(
_collection->dbce()->getIndex(opCtx, _collection->getCatalogEntry(), entry.get()));
entry->init(std::move(accessMethod));
diff --git a/src/mongo/db/catalog/index_create.h b/src/mongo/db/catalog/index_create.h
index 3aabd68ed1c..62d9d29eb13 100644
--- a/src/mongo/db/catalog/index_create.h
+++ b/src/mongo/db/catalog/index_create.h
@@ -34,6 +34,7 @@
#include <vector>
#include "mongo/base/disallow_copying.h"
+#include "mongo/base/shim.h"
#include "mongo/base/status.h"
#include "mongo/db/catalog/index_catalog.h"
#include "mongo/db/catalog/index_catalog_impl.h"