diff options
author | Justin Seyster <justin.seyster@mongodb.com> | 2022-06-29 12:32:12 -0400 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2022-06-29 20:02:02 +0000 |
commit | cb9472afc30d32d1c18691d64899c1aa72cdc43d (patch) | |
tree | 924020b6f50ccf365926a2420c64d92e5497a34a /src/mongo/db/sorter | |
parent | f684488a8509f0a3764fa48221499b9cd508c0e1 (diff) | |
download | mongo-cb9472afc30d32d1c18691d64899c1aa72cdc43d.tar.gz |
SERVER-65481 Bulk shredding and loading for column store indexes
Diffstat (limited to 'src/mongo/db/sorter')
-rw-r--r-- | src/mongo/db/sorter/sorter.cpp | 6 | ||||
-rw-r--r-- | src/mongo/db/sorter/sorter.h | 13 |
2 files changed, 13 insertions, 6 deletions
diff --git a/src/mongo/db/sorter/sorter.cpp b/src/mongo/db/sorter/sorter.cpp index c23c2695afd..ecb9e10118e 100644 --- a/src/mongo/db/sorter/sorter.cpp +++ b/src/mongo/db/sorter/sorter.cpp @@ -1291,11 +1291,11 @@ void SortedFileWriter<Key, Value>::addAlreadySorted(const Key& key, const Value& addDataToChecksum(_buffer.buf() + _nextObjPos, _buffer.len() - _nextObjPos, _checksum); if (_buffer.len() > static_cast<int>(kSortedFileBufferSize)) - spill(); + writeChunk(); } template <typename Key, typename Value> -void SortedFileWriter<Key, Value>::spill() { +void SortedFileWriter<Key, Value>::writeChunk() { int32_t size = _buffer.len(); char* outBuffer = _buffer.buf(); @@ -1340,7 +1340,7 @@ void SortedFileWriter<Key, Value>::spill() { template <typename Key, typename Value> SortIteratorInterface<Key, Value>* SortedFileWriter<Key, Value>::done() { - spill(); + writeChunk(); return new sorter::FileIterator<Key, Value>( _file, _fileStartOffset, _file->currentOffset(), _settings, _dbName, _checksum); diff --git a/src/mongo/db/sorter/sorter.h b/src/mongo/db/sorter/sorter.h index 12bccee1178..85c0f279ac2 100644 --- a/src/mongo/db/sorter/sorter.h +++ b/src/mongo/db/sorter/sorter.h @@ -592,16 +592,23 @@ public: void addAlreadySorted(const Key&, const Value&); /** - * Spills any data remaining in the buffer to disk and then closes the file to which data was + * Writes any data remaining in the buffer to disk and then closes the file to which data was * written. * * No more data can be added via addAlreadySorted() after calling done(). */ Iterator* done(); -private: - void spill(); + /** + * The SortedFileWriter organizes data into chunks, with a chunk getting written to the output + * file when it exceends a maximum chunks size. A SortedFilerWriter client can produce a short + * chunk by manually calling this function. + * + * If no new data has been added since the last chunk was written, this function is a no-op. + */ + void writeChunk(); +private: const Settings _settings; std::shared_ptr<typename Sorter<Key, Value>::File> _file; BufBuilder _buffer; |