diff options
Diffstat (limited to 'src/mongo/db/sorter/sorter.cpp')
-rw-r--r-- | src/mongo/db/sorter/sorter.cpp | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/src/mongo/db/sorter/sorter.cpp b/src/mongo/db/sorter/sorter.cpp index 39639153d7b..c5f6471c1d5 100644 --- a/src/mongo/db/sorter/sorter.cpp +++ b/src/mongo/db/sorter/sorter.cpp @@ -859,14 +859,15 @@ private: template <typename Key, typename Value> Sorter<Key, Value>::Sorter(const SortOptions& opts) : _opts(opts), - _file(opts.extSortAllowed - ? std::make_shared<Sorter<Key, Value>::File>(opts.tempDir + "/" + nextFileName()) - : nullptr) {} + _file(opts.extSortAllowed ? std::make_shared<Sorter<Key, Value>::File>( + opts.tempDir + "/" + nextFileName(), opts.sorterFileStats) + : nullptr) {} template <typename Key, typename Value> Sorter<Key, Value>::Sorter(const SortOptions& opts, const std::string& fileName) : _opts(opts), - _file(std::make_shared<Sorter<Key, Value>::File>(opts.tempDir + "/" + fileName)) { + _file(std::make_shared<Sorter<Key, Value>::File>(opts.tempDir + "/" + fileName, + opts.sorterFileStats)) { invariant(opts.extSortAllowed); invariant(!opts.tempDir.empty()); invariant(!fileName.empty()); @@ -874,6 +875,10 @@ Sorter<Key, Value>::Sorter(const SortOptions& opts, const std::string& fileName) template <typename Key, typename Value> Sorter<Key, Value>::File::~File() { + if (_stats && _file.is_open()) { + _stats->closed.addAndFetch(1); + } + if (_keep) { return; } @@ -964,6 +969,10 @@ void Sorter<Key, Value>::File::_open() { str::stream() << "Error opening file " << _path.string() << ": " << sorter::myErrnoWithDescription(), _file.good()); + + if (_stats) { + _stats->opened.addAndFetch(1); + } } template <typename Key, typename Value> |