summaryrefslogtreecommitdiff
path: root/src/mongo/db/query/plan_executor_impl.h
diff options
context:
space:
mode:
authorDavid Storch <david.storch@mongodb.com>2020-06-24 18:38:08 -0400
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2020-07-09 14:14:43 +0000
commita58d7ea75368b103a7f493c0ff6035b9a099b88d (patch)
tree971c74fde502d5549d46b5e63bcc7b854fb78f32 /src/mongo/db/query/plan_executor_impl.h
parentc37aaac0696c3b4a69df191bd991e474824e43b1 (diff)
downloadmongo-a58d7ea75368b103a7f493c0ff6035b9a099b88d.tar.gz
SERVER-48477 Make PlanExecutor interface more generic
After this change, the interface is sensible for both the classic and SBE engines (with the exception of 'getRootStage()' which is left as future work).
Diffstat (limited to 'src/mongo/db/query/plan_executor_impl.h')
-rw-r--r--src/mongo/db/query/plan_executor_impl.h64
1 files changed, 25 insertions, 39 deletions
diff --git a/src/mongo/db/query/plan_executor_impl.h b/src/mongo/db/query/plan_executor_impl.h
index ac1bcd8e43b..ba0bdd58a9b 100644
--- a/src/mongo/db/query/plan_executor_impl.h
+++ b/src/mongo/db/query/plan_executor_impl.h
@@ -32,79 +32,70 @@
#include <boost/optional.hpp>
#include <queue>
+#include "mongo/db/exec/working_set.h"
#include "mongo/db/query/plan_executor.h"
+#include "mongo/db/query/query_solution.h"
namespace mongo {
+class CappedInsertNotifier;
+struct CappedInsertNotifierData;
+
class PlanExecutorImpl : public PlanExecutor {
PlanExecutorImpl(const PlanExecutorImpl&) = delete;
PlanExecutorImpl& operator=(const PlanExecutorImpl&) = delete;
public:
/**
- * Public factory methods delegate to this impl factory to do their work.
+ * Callers should obtain PlanExecutorImpl instances uses the 'plan_executor_factory' methods, in
+ * order to avoid depending directly on this concrete implementation of the PlanExecutor
+ * interface.
*/
- static StatusWith<std::unique_ptr<PlanExecutor, PlanExecutor::Deleter>> make(
- OperationContext* opCtx,
- std::unique_ptr<WorkingSet> ws,
- std::unique_ptr<PlanStage> rt,
- std::unique_ptr<QuerySolution> qs,
- std::unique_ptr<CanonicalQuery> cq,
- const boost::intrusive_ptr<ExpressionContext>& expCtx,
- const Collection* collection,
- NamespaceString nss,
- PlanYieldPolicy::YieldPolicy yieldPolicy);
+ PlanExecutorImpl(OperationContext* opCtx,
+ std::unique_ptr<WorkingSet> ws,
+ std::unique_ptr<PlanStage> rt,
+ std::unique_ptr<QuerySolution> qs,
+ std::unique_ptr<CanonicalQuery> cq,
+ const boost::intrusive_ptr<ExpressionContext>& expCtx,
+ const Collection* collection,
+ NamespaceString nss,
+ PlanYieldPolicy::YieldPolicy yieldPolicy);
virtual ~PlanExecutorImpl();
- WorkingSet* getWorkingSet() const final;
PlanStage* getRootStage() const final;
CanonicalQuery* getCanonicalQuery() const final;
const NamespaceString& nss() const final;
OperationContext* getOpCtx() const final;
- const boost::intrusive_ptr<ExpressionContext>& getExpCtx() const final;
void saveState() final;
void restoreState() final;
void detachFromOperationContext() final;
void reattachToOperationContext(OperationContext* opCtx) final;
- void restoreStateWithoutRetrying() final;
- ExecState getNextSnapshotted(Snapshotted<Document>* objOut, RecordId* dlOut) final;
- ExecState getNextSnapshotted(Snapshotted<BSONObj>* objOut, RecordId* dlOut) final;
- ExecState getNext(Document* objOut, RecordId* dlOut) final;
+ ExecState getNextDocument(Document* objOut, RecordId* dlOut) final;
ExecState getNext(BSONObj* out, RecordId* dlOut) final;
bool isEOF() final;
void executePlan() final;
void markAsKilled(Status killStatus) final;
void dispose(OperationContext* opCtx) final;
- void enqueue(const Document& obj) final;
void enqueue(const BSONObj& obj) final;
bool isMarkedAsKilled() const final;
Status getKillStatus() final;
bool isDisposed() const final;
- bool isDetached() const final;
Timestamp getLatestOplogTimestamp() const final;
BSONObj getPostBatchResumeToken() const final;
LockPolicy lockPolicy() const final;
bool isPipelineExecutor() const final;
-private:
/**
- * New PlanExecutor instances are created with the static make() method above.
+ * Same as restoreState() but without the logic to retry if a WriteConflictException is thrown.
+ *
+ * This is only public for PlanYieldPolicy. DO NOT CALL ANYWHERE ELSE.
*/
- PlanExecutorImpl(OperationContext* opCtx,
- std::unique_ptr<WorkingSet> ws,
- std::unique_ptr<PlanStage> rt,
- std::unique_ptr<QuerySolution> qs,
- std::unique_ptr<CanonicalQuery> cq,
- const boost::intrusive_ptr<ExpressionContext>& expCtx,
- const Collection* collection,
- NamespaceString nss,
- PlanYieldPolicy::YieldPolicy yieldPolicy);
+ void restoreStateWithoutRetrying();
+private:
/**
- * Clients of PlanExecutor expect that on receiving a new instance from one of the make()
- * factory methods, plan selection has already been completed. In order to enforce this
- * property, this function is called to do plan selection prior to returning the new
- * PlanExecutor.
+ * Called on construction in order to ensure that when callers receive a new instance of a
+ * 'PlanExecutorImpl', plan selection has already been completed.
*
* If the tree contains plan selection stages, such as MultiPlanStage or SubplanStage,
* this calls into their underlying plan selection facilities. Otherwise, does nothing.
@@ -144,9 +135,6 @@ private:
*/
void _waitForInserts(CappedInsertNotifierData* notifierData);
- /**
- * Common implementation for getNext() and getNextSnapshotted().
- */
ExecState _getNextImpl(Snapshotted<Document>* objOut, RecordId* dlOut);
// The OperationContext that we're executing within. This can be updated if necessary by using
@@ -189,8 +177,6 @@ private:
enum { kUsable, kSaved, kDetached, kDisposed } _currentState = kUsable;
- bool _everDetachedFromOperationContext = false;
-
// A pointer either to a ChangeStreamProxy or a CollectionScan stage, if present in the
// execution tree, or nullptr otherwise. We cache it to avoid the need to traverse the execution
// tree in runtime when the executor is requested to return the oplog tracking info. Since this