diff options
author | Jordi Olivares Provencio <jordi.olivares-provencio@mongodb.com> | 2022-02-22 09:33:01 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2022-02-22 10:02:10 +0000 |
commit | 6f2f8c761f3e23b2f8c8a03d45f5c5ef3d6e86b1 (patch) | |
tree | 6baff8c6fab970a25c47a35171b5c280690fd966 /src/mongo/db/index | |
parent | d6d2fc0b95c4bf5691c34f162b605d0213fb43fb (diff) | |
download | mongo-6f2f8c761f3e23b2f8c8a03d45f5c5ef3d6e86b1.tar.gz |
SERVER-63033 Refactor resumable index builds to use IDL instead of manual BSON building
Diffstat (limited to 'src/mongo/db/index')
-rw-r--r-- | src/mongo/db/index/SConscript | 1 | ||||
-rw-r--r-- | src/mongo/db/index/index_access_method.cpp | 18 | ||||
-rw-r--r-- | src/mongo/db/index/index_access_method.h | 3 |
3 files changed, 9 insertions, 13 deletions
diff --git a/src/mongo/db/index/SConscript b/src/mongo/db/index/SConscript index e8e12550fb6..b4e2e698104 100644 --- a/src/mongo/db/index/SConscript +++ b/src/mongo/db/index/SConscript @@ -104,6 +104,7 @@ serveronlyEnv.Library( '$BUILD_DIR/mongo/db/curop', '$BUILD_DIR/mongo/db/multi_key_path_tracker', '$BUILD_DIR/mongo/db/repl/repl_coordinator_interface', + '$BUILD_DIR/mongo/db/resumable_index_builds_idl', '$BUILD_DIR/mongo/db/service_context', '$BUILD_DIR/mongo/db/sorter/sorter_idl', '$BUILD_DIR/mongo/db/storage/encryption_hooks', diff --git a/src/mongo/db/index/index_access_method.cpp b/src/mongo/db/index/index_access_method.cpp index d291efd6105..aa0f401c91c 100644 --- a/src/mongo/db/index/index_access_method.cpp +++ b/src/mongo/db/index/index_access_method.cpp @@ -604,7 +604,7 @@ public: bool isMultikey() const final; - void persistDataForShutdown(BSONObjBuilder& builder) final; + IndexStateInfo persistDataForShutdown() final; private: void _yield(OperationContext* opCtx, @@ -745,20 +745,16 @@ bool SortedDataIndexAccessMethod::BulkBuilderImpl::isMultikey() const { return _isMultiKey; } -void SortedDataIndexAccessMethod::BulkBuilderImpl::persistDataForShutdown(BSONObjBuilder& builder) { +IndexStateInfo SortedDataIndexAccessMethod::BulkBuilderImpl::persistDataForShutdown() { _insertMultikeyMetadataKeysIntoSorter(); auto state = _sorter->persistDataForShutdown(); - builder.append("fileName", state.fileName); - builder.append("numKeys", _keysInserted); + IndexStateInfo stateInfo; + stateInfo.setFileName(StringData(state.fileName)); + stateInfo.setNumKeys(_keysInserted); + stateInfo.setRanges(std::move(state.ranges)); - BSONArrayBuilder ranges(builder.subarrayStart("ranges")); - for (const auto& rangeInfo : state.ranges) { - BSONObjBuilder range(ranges.subobjStart()); - range.append("startOffset", rangeInfo.getStartOffset()); - range.append("endOffset", rangeInfo.getEndOffset()); - range.append("checksum", rangeInfo.getChecksum()); - } + return stateInfo; } void SortedDataIndexAccessMethod::BulkBuilderImpl::_insertMultikeyMetadataKeysIntoSorter() { diff --git a/src/mongo/db/index/index_access_method.h b/src/mongo/db/index/index_access_method.h index 2fe9efc1778..c9e85ff5d43 100644 --- a/src/mongo/db/index/index_access_method.h +++ b/src/mongo/db/index/index_access_method.h @@ -217,9 +217,8 @@ public: /** * Persists on disk the keys that have been inserted using this BulkBuilder. - * Appends necessary information to resume building to passed-in builder. */ - virtual void persistDataForShutdown(BSONObjBuilder& builder) = 0; + virtual IndexStateInfo persistDataForShutdown() = 0; }; /** |