diff options
author | Gregory Wlodarek <gregory.wlodarek@mongodb.com> | 2022-02-01 17:56:19 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2022-02-02 23:47:16 +0000 |
commit | 3e6f04a2fd96c2a411e25630e0499a09689a8799 (patch) | |
tree | 450607858f7f7505617dcb1b7775087cc9f88b31 | |
parent | a259083f1162f96b8380808b6c2fc6e4551130b4 (diff) | |
download | mongo-3e6f04a2fd96c2a411e25630e0499a09689a8799.tar.gz |
SERVER-62610 Add a function to the durable catalog to fetch all index idents for a catalog entry
-rw-r--r-- | src/mongo/db/storage/durable_catalog.h | 2 | ||||
-rw-r--r-- | src/mongo/db/storage/durable_catalog_impl.cpp | 21 | ||||
-rw-r--r-- | src/mongo/db/storage/durable_catalog_impl.h | 2 |
3 files changed, 25 insertions, 0 deletions
diff --git a/src/mongo/db/storage/durable_catalog.h b/src/mongo/db/storage/durable_catalog.h index 24c61455531..1f3c25e145d 100644 --- a/src/mongo/db/storage/durable_catalog.h +++ b/src/mongo/db/storage/durable_catalog.h @@ -81,6 +81,8 @@ public: RecordId id, StringData idxName) const = 0; + virtual std::vector<std::string> getIndexIdents(OperationContext* opCtx, RecordId id) const = 0; + virtual BSONObj getCatalogEntry(OperationContext* opCtx, RecordId catalogId) const = 0; virtual std::shared_ptr<BSONCollectionCatalogEntry::MetaData> getMetaData( diff --git a/src/mongo/db/storage/durable_catalog_impl.cpp b/src/mongo/db/storage/durable_catalog_impl.cpp index fa5d38bb9f2..3fd2766f798 100644 --- a/src/mongo/db/storage/durable_catalog_impl.cpp +++ b/src/mongo/db/storage/durable_catalog_impl.cpp @@ -403,6 +403,27 @@ std::string DurableCatalogImpl::getIndexIdent(OperationContext* opCtx, return idxIdent[idxName].String(); } +std::vector<std::string> DurableCatalogImpl::getIndexIdents(OperationContext* opCtx, + RecordId catalogId) const { + std::vector<std::string> idents; + + BSONObj obj = _findEntry(opCtx, catalogId); + if (obj["idxIdent"].eoo()) { + // No index entries for this catalog entry. + return idents; + } + + BSONObj idxIdent = obj["idxIdent"].Obj(); + + BSONObjIterator it(idxIdent); + while (it.more()) { + BSONElement elem = it.next(); + idents.push_back(elem.String()); + } + + return idents; +} + BSONObj DurableCatalogImpl::_findEntry(OperationContext* opCtx, RecordId catalogId) const { LOGV2_DEBUG(22208, 3, "looking up metadata for: {catalogId}", "catalogId"_attr = catalogId); RecordData data; diff --git a/src/mongo/db/storage/durable_catalog_impl.h b/src/mongo/db/storage/durable_catalog_impl.h index 264130a8536..63732d5846f 100644 --- a/src/mongo/db/storage/durable_catalog_impl.h +++ b/src/mongo/db/storage/durable_catalog_impl.h @@ -72,6 +72,8 @@ public: RecordId catalogId, StringData idxName) const; + std::vector<std::string> getIndexIdents(OperationContext* opCtx, RecordId catalogId) const; + BSONObj getCatalogEntry(OperationContext* opCtx, RecordId catalogId) const { return _findEntry(opCtx, catalogId); } |