summaryrefslogtreecommitdiff
path: root/src/mongo/db/pipeline/window_function/partition_iterator.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/db/pipeline/window_function/partition_iterator.cpp')
-rw-r--r--src/mongo/db/pipeline/window_function/partition_iterator.cpp23
1 files changed, 7 insertions, 16 deletions
diff --git a/src/mongo/db/pipeline/window_function/partition_iterator.cpp b/src/mongo/db/pipeline/window_function/partition_iterator.cpp
index 83925b862b3..d8992aec28c 100644
--- a/src/mongo/db/pipeline/window_function/partition_iterator.cpp
+++ b/src/mongo/db/pipeline/window_function/partition_iterator.cpp
@@ -116,8 +116,8 @@ optional<Document> PartitionIterator::operator[](int index) {
for (int i = _cache->getHighestIndex(); i < docDesired; i++) {
// Pull in document from prior stage.
getNextDocument();
- // Check whether the next document is available.
- if (isPaused() || _state == IteratorState::kAwaitingAdvanceToNext ||
+ // Check for EOF or the next partition.
+ if (_state == IteratorState::kAwaitingAdvanceToNext ||
_state == IteratorState::kAwaitingAdvanceToEOF) {
return boost::none;
}
@@ -163,7 +163,6 @@ PartitionIterator::AdvanceResult PartitionIterator::advanceInternal() {
// whether to pull from the prior stage.
switch (_state) {
case IteratorState::kNotInitialized:
- case IteratorState::kPauseExecution:
case IteratorState::kIntraPartition:
// Pull in the next document and advance the pointer.
getNextDocument();
@@ -302,13 +301,8 @@ optional<std::pair<int, int>> PartitionIterator::getEndpointsRangeBased(
for (int i = start; (doc = (*this)[i]); ++i) {
Value v = (*_sortExpr)->evaluate(*doc, &_expCtx->variables);
if (!lessThan(v, threshold)) {
- // This is the first doc we've scanned that crossed the threshold,
- // so it's the first doc in the window (as long as it's the expected type).
- if (hasExpectedType(v)) {
- return i;
- } else {
- return boost::none;
- }
+ // This is the first doc we've scanned that crossed the threshold.
+ return i;
}
}
// We scanned every document in the partition, and none crossed the
@@ -473,20 +467,17 @@ void PartitionIterator::getNextDocument() {
return;
}
- if (getNextRes.isPaused()) {
- _state = IteratorState::kPauseExecution;
+ if (!getNextRes.isAdvanced())
return;
- }
- tassert(7169100, "getNextResult must have advanced", getNextRes.isAdvanced());
auto doc = getNextRes.releaseDocument();
// Greedily populate the internal document cache to enable easier memory tracking versus
// detecting the changing document size during execution of each function.
- doc = doc.shred();
+ doc.fillCache();
if (_partitionExpr) {
- if (!_partitionComparator) {
+ if (_state == IteratorState::kNotInitialized) {
_partitionComparator =
std::make_unique<PartitionKeyComparator>(_expCtx, *_partitionExpr, doc);
_nextPartitionDoc = std::move(doc);