summaryrefslogtreecommitdiff
path: root/src/mongo/db/pipeline/document_source_densify.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/db/pipeline/document_source_densify.cpp')
-rw-r--r--src/mongo/db/pipeline/document_source_densify.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/mongo/db/pipeline/document_source_densify.cpp b/src/mongo/db/pipeline/document_source_densify.cpp
index 740ef193431..ab43e159692 100644
--- a/src/mongo/db/pipeline/document_source_densify.cpp
+++ b/src/mongo/db/pipeline/document_source_densify.cpp
@@ -335,10 +335,19 @@ DocumentSource::GetNextResult DocumentSourceInternalDensify::densifyExplicitRang
RangeStatement(_range.getStep(),
ExplicitBounds(bounds.first, bounds.second),
_range.getUnit()));
+ } else if (_current < bounds.first) {
+ // All the documents we saw were below the explicit range, so _current is below the range.
+ // Densification starts at the first bounds, so _current is no longer relevant.
+ createDocGenerator(bounds.first,
+ RangeStatement(_range.getStep(),
+ ExplicitBounds(bounds.first, bounds.second),
+ _range.getUnit()));
+
} else if (_current->increment(_range) >= bounds.second) {
_densifyState = DensifyState::kDensifyDone;
return DocumentSource::GetNextResult::makeEOF();
} else {
+ // _current is somewhere in the middle of the range.
auto lowerBound = _current->increment(_range);
createDocGenerator(lowerBound,
RangeStatement(_range.getStep(),