summaryrefslogtreecommitdiff
path: root/src/mongo/db/pipeline/document_source_group.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/db/pipeline/document_source_group.cpp')
-rw-r--r--src/mongo/db/pipeline/document_source_group.cpp11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/mongo/db/pipeline/document_source_group.cpp b/src/mongo/db/pipeline/document_source_group.cpp
index 2ab40378383..73f3a76d81d 100644
--- a/src/mongo/db/pipeline/document_source_group.cpp
+++ b/src/mongo/db/pipeline/document_source_group.cpp
@@ -549,11 +549,16 @@ private:
} // namespace
DocumentSource::GetNextResult DocumentSourceGroup::initialize() {
- const size_t numAccumulators = _accumulatedFields.size();
-
- // Barring any pausing, this loop exhausts 'pSource' and populates '_groups'.
GetNextResult input = pSource->getNext();
+ return initializeSelf(input);
+}
+// This separate NOINLINE function is used here to decrease stack utilization of initialize() and
+// prevent stack overflows.
+MONGO_COMPILER_NOINLINE DocumentSource::GetNextResult DocumentSourceGroup::initializeSelf(
+ GetNextResult input) {
+ const size_t numAccumulators = _accumulatedFields.size();
+ // Barring any pausing, this loop exhausts 'pSource' and populates '_groups'.
for (; input.isAdvanced(); input = pSource->getNext()) {
if (shouldSpillWithAttemptToSaveMemory()) {
_sortedFiles.push_back(spill());