diff options
author | Jennifer Peshansky <jennifer.peshansky@mongodb.com> | 2022-11-03 16:13:20 +0000 |
---|---|---|
committer | Jennifer Peshansky <jennifer.peshansky@mongodb.com> | 2022-11-03 16:13:20 +0000 |
commit | e74d2910bbe76790ad131d53fee277829cd95982 (patch) | |
tree | cabe148764529c9623652374fbc36323a550cd44 /src/mongo/db/catalog/virtual_collection_impl.h | |
parent | 280145e9940729480bb8a35453d4056afac87641 (diff) | |
parent | ba467f46cc1bc49965e1d72b541eff0cf1d7b22e (diff) | |
download | mongo-e74d2910bbe76790ad131d53fee277829cd95982.tar.gz |
Merge branch 'master' into jenniferpeshansky/SERVER-70854jenniferpeshansky/SERVER-70854
Diffstat (limited to 'src/mongo/db/catalog/virtual_collection_impl.h')
-rw-r--r-- | src/mongo/db/catalog/virtual_collection_impl.h | 78 |
1 files changed, 48 insertions, 30 deletions
diff --git a/src/mongo/db/catalog/virtual_collection_impl.h b/src/mongo/db/catalog/virtual_collection_impl.h index a490f4f9ee1..499e6add895 100644 --- a/src/mongo/db/catalog/virtual_collection_impl.h +++ b/src/mongo/db/catalog/virtual_collection_impl.h @@ -50,19 +50,20 @@ public: const CollectionOptions& options, std::unique_ptr<ExternalRecordStore> recordStore); + VirtualCollectionImpl(const VirtualCollectionImpl&) = default; + ~VirtualCollectionImpl() = default; const VirtualCollectionOptions& getVirtualCollectionOptions() const { - return _recordStore->getOptions(); + return _shared->_recordStore->getOptions(); } std::shared_ptr<Collection> clone() const final { - unimplementedTasserted(); - return nullptr; + return std::make_shared<VirtualCollectionImpl>(*this); } SharedCollectionDecorations* getSharedDecorations() const final { - return nullptr; + return &_shared->_sharedDecorations; } Status initFromExisting(OperationContext* opCtx, @@ -96,19 +97,21 @@ public: } const IndexCatalog* getIndexCatalog() const final { - return nullptr; + return _indexCatalog.get(); } IndexCatalog* getIndexCatalog() final { - return nullptr; + return _indexCatalog.get(); } RecordStore* getRecordStore() const final { - return _recordStore.get(); + return _shared->_recordStore.get(); } + // A virtual collection can't have an 'ident' because 'ident' is an identifier to a WT table + // which a virtual colelction does not have. So returns nullptr. std::shared_ptr<Ident> getSharedIdent() const final { - return _recordStore->getSharedIdent(); + return nullptr; } void setIdent(std::shared_ptr<Ident> newIdent) final { @@ -149,7 +152,7 @@ public: std::unique_ptr<SeekableRecordCursor> getCursor(OperationContext* opCtx, bool forward = true) const final { - return _recordStore->getCursor(opCtx, forward); + return _shared->_recordStore->getCursor(opCtx, forward); } void deleteDocument( @@ -368,35 +371,26 @@ public: } int getTotalIndexCount() const final { - unimplementedTasserted(); return 0; } int getCompletedIndexCount() const final { - unimplementedTasserted(); return 0; } BSONObj getIndexSpec(StringData indexName) const final { - unimplementedTasserted(); return BSONObj(); } - void getAllIndexes(std::vector<std::string>* names) const final { - unimplementedTasserted(); - } + void getAllIndexes(std::vector<std::string>* names) const final {} - void getReadyIndexes(std::vector<std::string>* names) const final { - unimplementedTasserted(); - } + void getReadyIndexes(std::vector<std::string>* names) const final {} bool isIndexPresent(StringData indexName) const final { - unimplementedTasserted(); return false; } bool isIndexReady(StringData indexName) const final { - unimplementedTasserted(); return false; } @@ -428,15 +422,15 @@ public: } long long numRecords(OperationContext* opCtx) const final { - return _recordStore->numRecords(opCtx); + return _shared->_recordStore->numRecords(opCtx); } long long dataSize(OperationContext* opCtx) const final { - return _recordStore->dataSize(opCtx); + return _shared->_recordStore->dataSize(opCtx); } bool isEmpty(OperationContext* opCtx) const final { - return _recordStore->dataSize(opCtx) == 0LL; + return _shared->_recordStore->dataSize(opCtx) == 0LL; } inline int averageObjectSize(OperationContext* opCtx) const { @@ -478,7 +472,7 @@ public: * Collection is destroyed. */ const CollatorInterface* getDefaultCollator() const final { - return _collator.get(); + return _shared->_collator.get(); } const CollectionOptions& getCollectionOptions() const final { @@ -491,12 +485,17 @@ public: return Status(ErrorCodes::UnknownError, "unknown"); } + // This method is used in context of rollback and index build which are not supported for a + // virtual collection. std::unique_ptr<PlanExecutor, PlanExecutor::Deleter> makePlanExecutor( OperationContext* opCtx, const CollectionPtr& yieldableCollection, PlanYieldPolicy::YieldPolicy yieldPolicy, ScanDirection scanDirection, - const boost::optional<RecordId>& resumeAfterRecordId) const final; + const boost::optional<RecordId>& resumeAfterRecordId) const final { + unimplementedTasserted(); + return nullptr; + } void indexBuildSuccess(OperationContext* opCtx, IndexCatalogEntry* index) final { unimplementedTasserted(); @@ -509,13 +508,32 @@ private: MONGO_UNIMPLEMENTED_TASSERT(6968504); } + struct SharedState { + SharedState(std::unique_ptr<ExternalRecordStore> recordStore, + std::unique_ptr<CollatorInterface> collator) + : _recordStore(std::move(recordStore)), _collator(std::move(collator)) {} + + ~SharedState() = default; + + std::unique_ptr<ExternalRecordStore> _recordStore; + + // This object is decorable and decorated with unversioned data related to the collection. + // Not associated with any particular Collection instance for the collection, but shared + // across all instances for the same collection. This is a vehicle for users of a collection + // to cache unversioned state for a collection that is accessible across all of the + // Collection instances. + SharedCollectionDecorations _sharedDecorations; + + // 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. If null, the + // default collation is simple binary compare. + std::unique_ptr<CollatorInterface> _collator; + }; + NamespaceString _nss; CollectionOptions _options; - std::unique_ptr<ExternalRecordStore> _recordStore; - // 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. If null, the - // default collation is simple binary compare. - std::unique_ptr<CollatorInterface> _collator; + std::shared_ptr<SharedState> _shared; + clonable_ptr<IndexCatalog> _indexCatalog; }; } // namespace mongo |