diff options
Diffstat (limited to 'src/mongo/db/pipeline/skip_and_limit.cpp')
| -rw-r--r-- | src/mongo/db/pipeline/skip_and_limit.cpp | 33 |
1 files changed, 3 insertions, 30 deletions
diff --git a/src/mongo/db/pipeline/skip_and_limit.cpp b/src/mongo/db/pipeline/skip_and_limit.cpp index 0f9f7d3aca7..e9e7e9772ce 100644 --- a/src/mongo/db/pipeline/skip_and_limit.cpp +++ b/src/mongo/db/pipeline/skip_and_limit.cpp @@ -82,21 +82,8 @@ Pipeline::SourceContainer::iterator eraseAndStich(Pipeline::SourceContainer::ite } // namespace -/** - * If there are any $limit stages that could be logically swapped forward to the position of the - * pipeline pointed to by 'itr' without changing the meaning of the query, removes these $limit - * stages from the Pipeline and returns the resulting limit. A single limit value is computed by - * taking the minimum after swapping each individual $limit stage forward. - * - * This method also implements the ability to swap a $limit before a $skip, by adding the value of - * the $skip to the value of the $limit. - * - * If shouldModifyPipeline is false, this method does not swap any stages but rather just returns - * the single limit value described above. - */ -boost::optional<long long> extractLimitForPushdownHelper(Pipeline::SourceContainer::iterator itr, - Pipeline::SourceContainer* container, - bool shouldModifyPipeline) { +boost::optional<long long> extractLimitForPushdown(Pipeline::SourceContainer::iterator itr, + Pipeline::SourceContainer* container) { int64_t skipSum = 0; boost::optional<long long> minLimit; while (itr != container->end()) { @@ -117,11 +104,7 @@ boost::optional<long long> extractLimitForPushdownHelper(Pipeline::SourceContain minLimit = std::min(static_cast<long long>(safeSum), *minLimit); } - if (shouldModifyPipeline) { - itr = eraseAndStich(itr, container); - } else { - ++itr; - } + itr = eraseAndStich(itr, container); } else if (!nextStage->constraints().canSwapWithSkippingOrLimitingStage) { break; } else { @@ -132,16 +115,6 @@ boost::optional<long long> extractLimitForPushdownHelper(Pipeline::SourceContain return minLimit; } -boost::optional<long long> extractLimitForPushdown(Pipeline::SourceContainer::iterator itr, - Pipeline::SourceContainer* container) { - return extractLimitForPushdownHelper(itr, container, true /* shouldModifyPipeline */); -} - -boost::optional<long long> getUserLimit(Pipeline::SourceContainer::iterator itr, - Pipeline::SourceContainer* container) { - return extractLimitForPushdownHelper(itr, container, false /* shouldModifyPipeline */); -} - boost::optional<long long> extractSkipForPushdown(Pipeline::SourceContainer::iterator itr, Pipeline::SourceContainer* container) { boost::optional<long long> skipSum; |
