mirror of https://github.com/mongodb/mongo
SERVER-115036 Add tempDir, dbName, and ChecksumVersion to the FileBasedSorterStorage constructor (#44951)
GitOrigin-RevId: 831a9a28e49756e49296dde469a554ec93a1858b
This commit is contained in:
parent
0e4b035959
commit
1a6adfa86d
|
|
@ -106,7 +106,7 @@ void SpoolStage::spill() {
|
|||
auto opts = SortOptions().TempDir(expCtx()->getTempDir());
|
||||
opts.FileStats(_spillStats.get());
|
||||
|
||||
FileBasedSorterStorage<RecordId, NullValue> sorterStorage(_file);
|
||||
FileBasedSorterStorage<RecordId, NullValue> sorterStorage(_file, expCtx()->getTempDir());
|
||||
std::unique_ptr<SortedStorageWriter<RecordId, NullValue>> writer =
|
||||
sorterStorage.makeWriter(opts);
|
||||
// Do not spill the records that have been already consumed.
|
||||
|
|
|
|||
|
|
@ -255,7 +255,7 @@ void GroupProcessor::spill() {
|
|||
_file = std::make_shared<SorterFile>(sorter::nextFileName(_expCtx->getTempDir()),
|
||||
_spillStats.get());
|
||||
}
|
||||
FileBasedSorterStorage<Value, Value> sorterStorage(_file);
|
||||
FileBasedSorterStorage<Value, Value> sorterStorage(_file, _expCtx->getTempDir());
|
||||
std::unique_ptr<SortedStorageWriter<Value, Value>> writer =
|
||||
sorterStorage.makeWriter(SortOptions().TempDir(_expCtx->getTempDir()));
|
||||
switch (_accumulatedFields.size()) { // same as ptrs[i]->second.size() for all i.
|
||||
|
|
|
|||
|
|
@ -83,7 +83,7 @@ void AccuratePercentile::spill() {
|
|||
|
||||
_numTotalValuesSpilled += _accumulatedValues.size();
|
||||
|
||||
FileBasedSorterStorage<Value, Value> sorterStorage(_spillFile);
|
||||
FileBasedSorterStorage<Value, Value> sorterStorage(_spillFile, _expCtx->getTempDir());
|
||||
std::unique_ptr<SortedStorageWriter<Value, Value>> writer =
|
||||
sorterStorage.makeWriter(SortOptions().TempDir(_expCtx->getTempDir()));
|
||||
|
||||
|
|
|
|||
|
|
@ -461,7 +461,11 @@ public:
|
|||
typename Value::SorterDeserializeSettings>
|
||||
Settings;
|
||||
|
||||
explicit FileBasedSorterStorage(std::shared_ptr<SorterFile> file);
|
||||
explicit FileBasedSorterStorage(
|
||||
std::shared_ptr<SorterFile> file,
|
||||
boost::optional<boost::filesystem::path> pathToSpillDir,
|
||||
boost::optional<DatabaseName> dbName = boost::none,
|
||||
SorterChecksumVersion checksumVersion = SorterChecksumVersion::v2);
|
||||
|
||||
std::unique_ptr<SortedStorageWriter<Key, Value>> makeWriter(
|
||||
const SortOptions& opts, const Settings& settings = Settings()) override;
|
||||
|
|
@ -474,8 +478,17 @@ public:
|
|||
|
||||
size_t getIteratorSize() override;
|
||||
|
||||
boost::optional<boost::filesystem::path> getSpillDirPath();
|
||||
|
||||
boost::optional<DatabaseName> getDbName();
|
||||
|
||||
SorterChecksumVersion getChecksumVersion();
|
||||
|
||||
private:
|
||||
std::shared_ptr<SorterFile> _file;
|
||||
boost::optional<boost::filesystem::path> _pathToSpillDir;
|
||||
boost::optional<DatabaseName> _dbName;
|
||||
SorterChecksumVersion _checksumVersion;
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -77,7 +77,7 @@ private:
|
|||
int currentBufSize = 0;
|
||||
// TODO(SERVER-114085): Remove after adding SorterStorage to SortOptions.
|
||||
// TODO(SERVER-114080): Ensure testing of non-file-based sorter storage is comprehensive.
|
||||
FileBasedSorterStorage<IntWrapper, IntWrapper> sorterStorage(makeFile());
|
||||
FileBasedSorterStorage<IntWrapper, IntWrapper> sorterStorage(makeFile(), *opts->tempDir);
|
||||
std::unique_ptr<SortedStorageWriter<IntWrapper, IntWrapper>> sorter =
|
||||
sorterStorage.makeWriter(*opts);
|
||||
for (int i = 0; i < range; ++i) {
|
||||
|
|
|
|||
|
|
@ -196,12 +196,12 @@ public:
|
|||
opts.tempDir);
|
||||
|
||||
uassertStatusOK(ensureSufficientDiskSpaceForSpilling(
|
||||
*(opts.tempDir), internalQuerySpillingMinAvailableDiskSpaceBytes.load()));
|
||||
*opts.tempDir, internalQuerySpillingMinAvailableDiskSpaceBytes.load()));
|
||||
|
||||
auto spillsFile =
|
||||
std::make_shared<SorterFile>(nextFileName(*(opts.tempDir)), opts.sorterFileStats);
|
||||
std::make_shared<SorterFile>(nextFileName(*opts.tempDir), opts.sorterFileStats);
|
||||
// TODO(SERVER-114085): Remove after adding SorterStorage to SortOptions.
|
||||
FileBasedSorterStorage<Key, Value> sorterStorage(spillsFile);
|
||||
FileBasedSorterStorage<Key, Value> sorterStorage(spillsFile, *opts.tempDir);
|
||||
std::unique_ptr<SortedStorageWriter<Key, Value>> writer =
|
||||
sorterStorage.makeWriter(opts, settings);
|
||||
|
||||
|
|
@ -701,7 +701,7 @@ protected:
|
|||
iterators.swap(this->_iters);
|
||||
|
||||
std::shared_ptr<File> newSpillsFile = std::make_shared<File>(
|
||||
nextFileName(*(this->_opts.tempDir)), this->_opts.sorterFileStats);
|
||||
nextFileName(*this->_opts.tempDir), this->_opts.sorterFileStats);
|
||||
|
||||
LOGV2_DEBUG(6033103,
|
||||
1,
|
||||
|
|
@ -733,7 +733,8 @@ protected:
|
|||
|
||||
auto mergeIterator = Iterator::merge(spillsToMerge, this->_opts, _comp);
|
||||
// TODO(SERVER-114085): Remove after adding SorterStorage to SortOptions.
|
||||
FileBasedSorterStorage<Key, Value> sorterStorage(newSpillsFile);
|
||||
FileBasedSorterStorage<Key, Value> sorterStorage(newSpillsFile,
|
||||
*this->_opts.tempDir);
|
||||
std::unique_ptr<SortedStorageWriter<Key, Value>> writer =
|
||||
sorterStorage.makeWriter(this->_opts, _settings);
|
||||
uint64_t pairCount = 0;
|
||||
|
|
@ -954,7 +955,7 @@ private:
|
|||
sort();
|
||||
|
||||
// TODO(SERVER-114085): Remove after adding SorterStorage to SortOptions.
|
||||
FileBasedSorterStorage<Key, Value> sorterStorage(this->_file);
|
||||
FileBasedSorterStorage<Key, Value> sorterStorage(this->_file, *this->_opts.tempDir);
|
||||
std::unique_ptr<SortedStorageWriter<Key, Value>> writer =
|
||||
sorterStorage.makeWriter(this->_opts, this->_settings);
|
||||
for (auto& data : _data) {
|
||||
|
|
@ -1398,8 +1399,15 @@ typename Sorter<Key, Value>::PersistedState Sorter<Key, Value>::persistDataForSh
|
|||
//
|
||||
|
||||
template <typename Key, typename Value>
|
||||
FileBasedSorterStorage<Key, Value>::FileBasedSorterStorage(std::shared_ptr<SorterFile> file)
|
||||
: _file(std::move(file)){};
|
||||
FileBasedSorterStorage<Key, Value>::FileBasedSorterStorage(
|
||||
std::shared_ptr<SorterFile> file,
|
||||
boost::optional<boost::filesystem::path> pathToSpillDir,
|
||||
boost::optional<DatabaseName> dbName,
|
||||
SorterChecksumVersion checksumVersion)
|
||||
: _file(std::move(file)),
|
||||
_pathToSpillDir(pathToSpillDir),
|
||||
_dbName(dbName),
|
||||
_checksumVersion(checksumVersion) {}
|
||||
|
||||
template <typename Key, typename Value>
|
||||
std::unique_ptr<SortedStorageWriter<Key, Value>> FileBasedSorterStorage<Key, Value>::makeWriter(
|
||||
|
|
@ -1425,6 +1433,21 @@ size_t FileBasedSorterStorage<Key, Value>::getIteratorSize() {
|
|||
return sizeof(sorter::FileIterator<Key, Value>);
|
||||
}
|
||||
|
||||
template <typename Key, typename Value>
|
||||
boost::optional<boost::filesystem::path> FileBasedSorterStorage<Key, Value>::getSpillDirPath() {
|
||||
return _pathToSpillDir;
|
||||
}
|
||||
|
||||
template <typename Key, typename Value>
|
||||
boost::optional<DatabaseName> FileBasedSorterStorage<Key, Value>::getDbName() {
|
||||
return _dbName;
|
||||
}
|
||||
|
||||
template <typename Key, typename Value>
|
||||
SorterChecksumVersion FileBasedSorterStorage<Key, Value>::getChecksumVersion() {
|
||||
return _checksumVersion;
|
||||
}
|
||||
|
||||
//
|
||||
// SorterFile members
|
||||
//
|
||||
|
|
@ -1878,7 +1901,7 @@ void BoundedSorter<Key, Value, Comparator, BoundMaker>::_spill(size_t maxMemoryU
|
|||
|
||||
// Write out all the values from the heap in sorted order.
|
||||
// TODO(SERVER-114085): Remove after adding SorterStorage to SortOptions.
|
||||
FileBasedSorterStorage<Key, Value> sorterStorage(_file);
|
||||
FileBasedSorterStorage<Key, Value> sorterStorage(_file, _opts.tempDir);
|
||||
std::unique_ptr<SortedStorageWriter<Key, Value>> writer = sorterStorage.makeWriter(_opts, {});
|
||||
while (!_heap.empty()) {
|
||||
writer->addAlreadySorted(_heap.top().first, _heap.top().second);
|
||||
|
|
|
|||
|
|
@ -171,7 +171,7 @@ private:
|
|||
int currentBufSize = 0;
|
||||
// TODO(SERVER-114085): Remove after adding SorterStorage to SortOptions.
|
||||
// TODO(SERVER-114080): Ensure testing of non-file-based sorter storage is comprehensive.
|
||||
FileBasedSorterStorage<IntWrapper, IntWrapper> sorterStorage(makeFile());
|
||||
FileBasedSorterStorage<IntWrapper, IntWrapper> sorterStorage(makeFile(), *opts->tempDir);
|
||||
std::unique_ptr<SortedStorageWriter<IntWrapper, IntWrapper>> sorter =
|
||||
sorterStorage.makeWriter(*opts);
|
||||
for (int i = 0; i < range; ++i) {
|
||||
|
|
@ -435,7 +435,7 @@ TEST_F(SorterMakeFromExistingRangesTest, NextWithDeferredValues) {
|
|||
std::make_shared<SorterFile>(sorter::nextFileName(*(opts.tempDir)), opts.sorterFileStats);
|
||||
// TODO(SERVER-114085): Remove after adding SorterStorage to SortOptions.
|
||||
// TODO(SERVER-114080): Ensure testing of non-file-based sorter storage is comprehensive.
|
||||
FileBasedSorterStorage<IntWrapper, IntWrapper> sorterStorage(spillFile);
|
||||
FileBasedSorterStorage<IntWrapper, IntWrapper> sorterStorage(spillFile, *opts.tempDir);
|
||||
std::unique_ptr<SortedStorageWriter<IntWrapper, IntWrapper>> writer =
|
||||
sorterStorage.makeWriter(opts);
|
||||
writer->addAlreadySorted(pair1.first, pair1.second);
|
||||
|
|
|
|||
|
|
@ -257,7 +257,7 @@ std::shared_ptr<IWIterator> spillToFile(IteratorPtr inputIter, const unittest::T
|
|||
std::make_shared<SorterFile>(sorter::nextFileName(*(opts.tempDir)), opts.sorterFileStats);
|
||||
// TODO(SERVER-114085): Remove after adding SorterStorage to SortOptions.
|
||||
// TODO(SERVER-114080): Ensure testing of non-file-based sorter storage is comprehensive.
|
||||
FileBasedSorterStorage<IntWrapper, IntWrapper> sorterStorage(spillFile);
|
||||
FileBasedSorterStorage<IntWrapper, IntWrapper> sorterStorage(spillFile, *opts.tempDir);
|
||||
std::unique_ptr<SortedStorageWriter<IntWrapper, IntWrapper>> writer =
|
||||
sorterStorage.makeWriter(opts);
|
||||
while (inputIter->more()) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue