diff options
author | Gregory Noma <gregory.noma@gmail.com> | 2020-06-11 15:57:04 -0400 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2020-06-11 20:31:49 +0000 |
commit | a470fda78b89e8eee045ff76a7fed44da8f6700c (patch) | |
tree | 31ef4ccb9a8642279415b0ae1972d04bb60530f5 /src/mongo/db/index | |
parent | e485c1a8011d85682cb8dafa87ab92b9c23daa66 (diff) | |
download | mongo-a470fda78b89e8eee045ff76a7fed44da8f6700c.tar.gz |
SERVER-48414 Extend Sorter and BulkBuilder interfaces to return data for resuming index builds
Diffstat (limited to 'src/mongo/db/index')
-rw-r--r-- | src/mongo/db/index/index_access_method.cpp | 16 | ||||
-rw-r--r-- | src/mongo/db/index/index_access_method.h | 12 |
2 files changed, 28 insertions, 0 deletions
diff --git a/src/mongo/db/index/index_access_method.cpp b/src/mongo/db/index/index_access_method.cpp index 00980d9905f..a365dc163f8 100644 --- a/src/mongo/db/index/index_access_method.cpp +++ b/src/mongo/db/index/index_access_method.cpp @@ -471,6 +471,8 @@ public: int64_t getKeysInserted() const final; + State getState() const final; + private: std::unique_ptr<Sorter> _sorter; IndexCatalogEntry* _indexCatalogEntry; @@ -487,6 +489,10 @@ private: // These are inserted into the sorter after all normal data keys have been added, just // before the bulk build is committed. KeyStringSet _multikeyMetadataKeys; + + // The RecordId corresponding to the object most recently inserted using this BulkBuilder, or + // boost::none if nothing has been inserted into the sorter or done() has already been called. + boost::optional<RecordId> _lastRecordIdInserted; }; std::unique_ptr<IndexAccessMethod::BulkBuilder> AbstractIndexAccessMethod::initiateBulk( @@ -567,6 +573,7 @@ Status AbstractIndexAccessMethod::BulkBuilderImpl::insert(OperationContext* opCt _isMultiKey = _isMultiKey || _indexCatalogEntry->accessMethod()->shouldMarkIndexAsMultikey( keys->size(), _multikeyMetadataKeys, *multikeyPaths); + _lastRecordIdInserted = loc; return Status::OK(); } @@ -585,6 +592,7 @@ AbstractIndexAccessMethod::BulkBuilderImpl::done() { _sorter->add(keyString, mongo::NullValue()); ++_keysInserted; } + _lastRecordIdInserted = boost::none; return _sorter->done(); } @@ -592,6 +600,14 @@ int64_t AbstractIndexAccessMethod::BulkBuilderImpl::getKeysInserted() const { return _keysInserted; } +AbstractIndexAccessMethod::BulkBuilder::State AbstractIndexAccessMethod::BulkBuilderImpl::getState() + const { + return {_lastRecordIdInserted, + _sorter->getTempDir(), + _sorter->getFileName(), + _sorter->getRangeInfos()}; +} + Status AbstractIndexAccessMethod::commitBulk(OperationContext* opCtx, BulkBuilder* bulk, bool dupsAllowed, diff --git a/src/mongo/db/index/index_access_method.h b/src/mongo/db/index/index_access_method.h index bf41334ce1f..deb586ddeb6 100644 --- a/src/mongo/db/index/index_access_method.h +++ b/src/mongo/db/index/index_access_method.h @@ -205,6 +205,13 @@ public: public: using Sorter = mongo::Sorter<KeyString::Value, mongo::NullValue>; + struct State { + boost::optional<RecordId> lastRecordIdInserted; + std::string tempDir; + std::string fileName; + std::vector<SorterRangeInfo> ranges; + }; + virtual ~BulkBuilder() = default; /** @@ -229,6 +236,11 @@ public: * Returns number of keys inserted using this BulkBuilder. */ virtual int64_t getKeysInserted() const = 0; + + /** + * Returns the current state of this BulkBuilder and its underlying Sorter. + */ + virtual State getState() const = 0; }; /** |