diff --git a/src/mongo/db/pipeline/document_source_sort.cpp b/src/mongo/db/pipeline/document_source_sort.cpp index 38e72693d1de6..30ee3a5b2e2f1 100644 --- a/src/mongo/db/pipeline/document_source_sort.cpp +++ b/src/mongo/db/pipeline/document_source_sort.cpp @@ -136,7 +136,7 @@ void DocumentSourceSort::serializeToArray( << "mergePresorted" << (_mergingPresorted ? Value(true) : Value()) << "limit" - << (limitSrc ? Value(limitSrc->getLimit()) : Value()))))); + << (_limitSrc ? Value(_limitSrc->getLimit()) : Value()))))); } else { // one Value for $sort and maybe a Value for $limit MutableDocument inner(sortKeyPattern(SortKeySerialization::kForPipelineSerialization)); if (_mergingPresorted) { @@ -144,8 +144,8 @@ void DocumentSourceSort::serializeToArray( } array.push_back(Value(DOC(kStageName << inner.freeze()))); - if (limitSrc) { - limitSrc->serializeToArray(array); + if (_limitSrc) { + _limitSrc->serializeToArray(array); } } } @@ -155,7 +155,7 @@ void DocumentSourceSort::doDispose() { } long long DocumentSourceSort::getLimit() const { - return limitSrc ? limitSrc->getLimit() : -1; + return _limitSrc ? _limitSrc->getLimit() : -1; } Document DocumentSourceSort::sortKeyPattern(SortKeySerialization serializationMode) const { @@ -319,8 +319,8 @@ SortOptions DocumentSourceSort::makeSortOptions() const { verify(_sortPattern.size()); SortOptions opts; - if (limitSrc) - opts.limit = limitSrc->getLimit(); + if (_limitSrc) + opts.limit = _limitSrc->getLimit(); opts.maxMemoryUsageBytes = _maxMemoryUsageBytes; if (pExpCtx->allowDiskUse && !pExpCtx->inMongos) { @@ -529,7 +529,7 @@ std::list> DocumentSourceSort::getMergeSources() { other->sortKeyPattern(SortKeySerialization::kForPipelineSerialization).toBson(), pExpCtx->getCollator()}; other->_paths = _paths; - other->limitSrc = limitSrc; + other->_limitSrc = _limitSrc; other->_maxMemoryUsageBytes = _maxMemoryUsageBytes; other->_mergingPresorted = true; other->_rawSort = _rawSort; diff --git a/src/mongo/db/pipeline/document_source_sort.h b/src/mongo/db/pipeline/document_source_sort.h index d2ad1cd9ec408..36194bd2bfca4 100644 --- a/src/mongo/db/pipeline/document_source_sort.h +++ b/src/mongo/db/pipeline/document_source_sort.h @@ -74,7 +74,7 @@ class DocumentSourceSort final : public DocumentSource, public SplittableDocumen : ChangeStreamRequirement::kBlacklist); // Can't swap with a $match if a limit has been absorbed, as $match can't swap with $limit. - constraints.canSwapWithMatch = !limitSrc; + constraints.canSwapWithMatch = !_limitSrc; return constraints; } @@ -144,7 +144,7 @@ class DocumentSourceSort final : public DocumentSource, public SplittableDocumen }; boost::intrusive_ptr getLimitSrc() const { - return limitSrc; + return _limitSrc; } protected: @@ -242,8 +242,8 @@ class DocumentSourceSort final : public DocumentSource, public SplittableDocumen * the smallest limit. */ void setLimitSrc(boost::intrusive_ptr limit) { - if (!limitSrc || limit->getLimit() < limitSrc->getLimit()) { - limitSrc = limit; + if (!_limitSrc || limit->getLimit() < _limitSrc->getLimit()) { + _limitSrc = limit; } } @@ -258,7 +258,7 @@ class DocumentSourceSort final : public DocumentSource, public SplittableDocumen // The set of paths on which we're sorting. std::set _paths; - boost::intrusive_ptr limitSrc; + boost::intrusive_ptr _limitSrc; uint64_t _maxMemoryUsageBytes; bool _done;