summaryrefslogtreecommitdiff
path: root/src/mongo/db/query
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/db/query')
-rw-r--r--src/mongo/db/query/plan_executor.h10
-rw-r--r--src/mongo/db/query/plan_executor_impl.cpp6
-rw-r--r--src/mongo/db/query/plan_executor_impl.h4
-rw-r--r--src/mongo/db/query/plan_executor_sbe.cpp6
-rw-r--r--src/mongo/db/query/plan_executor_sbe.h4
-rw-r--r--src/mongo/db/query/plan_ranker.h2
-rw-r--r--src/mongo/db/query/sbe_runtime_planner.cpp2
7 files changed, 17 insertions, 17 deletions
diff --git a/src/mongo/db/query/plan_executor.h b/src/mongo/db/query/plan_executor.h
index 1d8b70057b6..9c6f2c7be5a 100644
--- a/src/mongo/db/query/plan_executor.h
+++ b/src/mongo/db/query/plan_executor.h
@@ -308,16 +308,16 @@ public:
virtual void dispose(OperationContext* opCtx) = 0;
/**
- * Stash the BSONObj so that it gets returned from the PlanExecutor on a later call to
- * getNext(). Implementations should NOT support returning queued BSON objects using
- * 'getNextDocument()'. Only 'getNext()' should return the queued BSON objects.
+ * Stash the BSONObj so that it gets returned from the PlanExecutor a subsequent call to
+ * getNext(). Implementations should NOT support returning stashed BSON objects using
+ * 'getNextDocument()'. Only 'getNext()' should return the stashed BSON objects.
*
- * Enqueued documents are returned in FIFO order. The queued results are exhausted before
+ * Enqueued documents are returned in LIFO order. The stashed results are exhausted before
* generating further results from the underlying query plan.
*
* Subsequent calls to getNext() must request the BSONObj and *not* the RecordId.
*/
- virtual void enqueue(const BSONObj& obj) = 0;
+ virtual void stashResult(const BSONObj& obj) = 0;
virtual bool isMarkedAsKilled() const = 0;
virtual Status getKillStatus() = 0;
diff --git a/src/mongo/db/query/plan_executor_impl.cpp b/src/mongo/db/query/plan_executor_impl.cpp
index 241b52ed58f..7492393ad6a 100644
--- a/src/mongo/db/query/plan_executor_impl.cpp
+++ b/src/mongo/db/query/plan_executor_impl.cpp
@@ -329,7 +329,7 @@ PlanExecutor::ExecState PlanExecutorImpl::_getNextImpl(Snapshotted<Document>* ob
if (!_stash.empty()) {
invariant(objOut && !dlOut);
*objOut = {SnapshotId(), _stash.front()};
- _stash.pop();
+ _stash.pop_front();
return PlanExecutor::ADVANCED;
}
@@ -571,8 +571,8 @@ long long PlanExecutorImpl::executeDelete() {
}
}
-void PlanExecutorImpl::enqueue(const BSONObj& obj) {
- _stash.push(Document{obj.getOwned()});
+void PlanExecutorImpl::stashResult(const BSONObj& obj) {
+ _stash.push_front(Document{obj.getOwned()});
}
bool PlanExecutorImpl::isMarkedAsKilled() const {
diff --git a/src/mongo/db/query/plan_executor_impl.h b/src/mongo/db/query/plan_executor_impl.h
index c4642dd777e..87137cdbd4d 100644
--- a/src/mongo/db/query/plan_executor_impl.h
+++ b/src/mongo/db/query/plan_executor_impl.h
@@ -81,7 +81,7 @@ public:
long long executeDelete() override;
void markAsKilled(Status killStatus) final;
void dispose(OperationContext* opCtx) final;
- void enqueue(const BSONObj& obj) final;
+ void stashResult(const BSONObj& obj) final;
bool isMarkedAsKilled() const final;
Status getKillStatus() final;
bool isDisposed() const final;
@@ -170,7 +170,7 @@ private:
// A stash of results generated by this plan that the user of the PlanExecutor didn't want
// to consume yet. We empty the queue before retrieving further results from the plan
// stages.
- std::queue<Document> _stash;
+ std::deque<Document> _stash;
// The output document that is used by getNext BSON API. This allows us to avoid constantly
// allocating and freeing DocumentStorage.
diff --git a/src/mongo/db/query/plan_executor_sbe.cpp b/src/mongo/db/query/plan_executor_sbe.cpp
index e1dded76398..791c345dc7b 100644
--- a/src/mongo/db/query/plan_executor_sbe.cpp
+++ b/src/mongo/db/query/plan_executor_sbe.cpp
@@ -183,10 +183,10 @@ void PlanExecutorSBE::dispose(OperationContext* opCtx) {
_isDisposed = true;
}
-void PlanExecutorSBE::enqueue(const BSONObj& obj) {
+void PlanExecutorSBE::stashResult(const BSONObj& obj) {
invariant(_state == State::kOpened);
invariant(!_isDisposed);
- _stash.push({obj.getOwned(), boost::none});
+ _stash.push_front({obj.getOwned(), boost::none});
}
PlanExecutor::ExecState PlanExecutorSBE::getNextDocument(Document* objOut, RecordId* dlOut) {
@@ -213,7 +213,7 @@ PlanExecutor::ExecState PlanExecutorSBE::getNext(BSONObj* out, RecordId* dlOut)
if (dlOut && recordId) {
*dlOut = *recordId;
}
- _stash.pop();
+ _stash.pop_front();
return PlanExecutor::ExecState::ADVANCED;
} else if (_root->getCommonStats()->isEOF) {
// If we had stashed elements and consumed them all, but the PlanStage has also
diff --git a/src/mongo/db/query/plan_executor_sbe.h b/src/mongo/db/query/plan_executor_sbe.h
index f20e399d36e..018d785f7bd 100644
--- a/src/mongo/db/query/plan_executor_sbe.h
+++ b/src/mongo/db/query/plan_executor_sbe.h
@@ -101,7 +101,7 @@ public:
void dispose(OperationContext* opCtx);
- void enqueue(const BSONObj& obj);
+ void stashResult(const BSONObj& obj);
bool isMarkedAsKilled() const override {
return !_killStatus.isOK();
@@ -163,7 +163,7 @@ private:
boost::optional<sbe::value::SlotId> _resumeRecordIdSlot;
- std::queue<std::pair<BSONObj, boost::optional<RecordId>>> _stash;
+ std::deque<std::pair<BSONObj, boost::optional<RecordId>>> _stash;
// If we are returning owned result (i.e. value is moved out of the result accessor) then its
// lifetime must extend up to the next getNext (or saveState).
BSONObj _lastGetNext;
diff --git a/src/mongo/db/query/plan_ranker.h b/src/mongo/db/query/plan_ranker.h
index 4389b0b1fec..63d4b25d57d 100644
--- a/src/mongo/db/query/plan_ranker.h
+++ b/src/mongo/db/query/plan_ranker.h
@@ -190,7 +190,7 @@ struct BaseCandidatePlan {
// non-OK status.
Status status{Status::OK()};
// Any results produced during the plan's execution prior to scoring are retained here.
- std::queue<ResultType> results;
+ std::deque<ResultType> results;
};
using CandidatePlan = BaseCandidatePlan<PlanStage*, WorkingSetID, WorkingSet*>;
diff --git a/src/mongo/db/query/sbe_runtime_planner.cpp b/src/mongo/db/query/sbe_runtime_planner.cpp
index 09e70caf434..c2eddab1eeb 100644
--- a/src/mongo/db/query/sbe_runtime_planner.cpp
+++ b/src/mongo/db/query/sbe_runtime_planner.cpp
@@ -74,7 +74,7 @@ FetchDocStatus fetchNextDocument(
invariant(state == PlanState::ADVANCED);
invariant(obj.isOwned());
- candidate->results.push({obj, {recordIdSlot != nullptr, recordId}});
+ candidate->results.push_back({obj, {recordIdSlot != nullptr, recordId}});
} catch (const ExceptionFor<ErrorCodes::QueryTrialRunCompleted>&) {
return FetchDocStatus::exitedEarly;
} catch (const ExceptionFor<ErrorCodes::QueryExceededMemoryLimitNoDiskUseAllowed>& ex) {