summaryrefslogtreecommitdiff
path: root/src/mongo/db/exec/cached_plan.h
diff options
context:
space:
mode:
authorMark Benvenuto <mark.benvenuto@mongodb.com>2015-06-20 00:22:50 -0400
committerMark Benvenuto <mark.benvenuto@mongodb.com>2015-06-20 10:56:02 -0400
commit9c2ed42daa8fbbef4a919c21ec564e2db55e8d60 (patch)
tree3814f79c10d7b490948d8cb7b112ac1dd41ceff1 /src/mongo/db/exec/cached_plan.h
parent01965cf52bce6976637ecb8f4a622aeb05ab256a (diff)
downloadmongo-9c2ed42daa8fbbef4a919c21ec564e2db55e8d60.tar.gz
SERVER-18579: Clang-Format - reformat code, no comment reflow
Diffstat (limited to 'src/mongo/db/exec/cached_plan.h')
-rw-r--r--src/mongo/db/exec/cached_plan.h218
1 files changed, 110 insertions, 108 deletions
diff --git a/src/mongo/db/exec/cached_plan.h b/src/mongo/db/exec/cached_plan.h
index ccc82d9cc7d..937b18a8ad2 100644
--- a/src/mongo/db/exec/cached_plan.h
+++ b/src/mongo/db/exec/cached_plan.h
@@ -42,118 +42,120 @@
namespace mongo {
- class PlanYieldPolicy;
+class PlanYieldPolicy;
+
+/**
+ * This stage outputs its mainChild, and possibly its backup child
+ * and also updates the cache.
+ *
+ * Preconditions: Valid RecordId.
+ *
+ */
+class CachedPlanStage : public PlanStage {
+public:
+ CachedPlanStage(OperationContext* txn,
+ Collection* collection,
+ WorkingSet* ws,
+ CanonicalQuery* cq,
+ const QueryPlannerParams& params,
+ size_t decisionWorks,
+ PlanStage* root);
+
+ virtual bool isEOF();
+
+ virtual StageState work(WorkingSetID* out);
+
+ virtual void saveState();
+ virtual void restoreState(OperationContext* opCtx);
+ virtual void invalidate(OperationContext* txn, const RecordId& dl, InvalidationType type);
+
+ virtual std::vector<PlanStage*> getChildren() const;
+
+ virtual StageType stageType() const {
+ return STAGE_CACHED_PLAN;
+ }
+
+ virtual PlanStageStats* getStats();
+
+ virtual const CommonStats* getCommonStats() const;
+
+ virtual const SpecificStats* getSpecificStats() const;
+
+ static const char* kStageType;
/**
- * This stage outputs its mainChild, and possibly its backup child
- * and also updates the cache.
+ * Runs the cached plan for a trial period, yielding during the trial period according to
+ * 'yieldPolicy'.
*
- * Preconditions: Valid RecordId.
+ * Feedback from the trial period is passed to the plan cache. If the performance is lower
+ * than expected, the old plan is evicted and a new plan is selected from scratch (again
+ * yielding according to 'yieldPolicy'). Otherwise, the cached plan is run.
+ */
+ Status pickBestPlan(PlanYieldPolicy* yieldPolicy);
+
+private:
+ /**
+ * Passes stats from the trial period run of the cached plan to the plan cache.
*
+ * If the plan cache entry is deleted before we get a chance to update it, then this
+ * is a no-op.
*/
- class CachedPlanStage : public PlanStage {
- public:
- CachedPlanStage(OperationContext* txn,
- Collection* collection,
- WorkingSet* ws,
- CanonicalQuery* cq,
- const QueryPlannerParams& params,
- size_t decisionWorks,
- PlanStage* root);
-
- virtual bool isEOF();
-
- virtual StageState work(WorkingSetID* out);
-
- virtual void saveState();
- virtual void restoreState(OperationContext* opCtx);
- virtual void invalidate(OperationContext* txn, const RecordId& dl, InvalidationType type);
-
- virtual std::vector<PlanStage*> getChildren() const;
-
- virtual StageType stageType() const { return STAGE_CACHED_PLAN; }
-
- virtual PlanStageStats* getStats();
-
- virtual const CommonStats* getCommonStats() const;
-
- virtual const SpecificStats* getSpecificStats() const;
-
- static const char* kStageType;
-
- /**
- * Runs the cached plan for a trial period, yielding during the trial period according to
- * 'yieldPolicy'.
- *
- * Feedback from the trial period is passed to the plan cache. If the performance is lower
- * than expected, the old plan is evicted and a new plan is selected from scratch (again
- * yielding according to 'yieldPolicy'). Otherwise, the cached plan is run.
- */
- Status pickBestPlan(PlanYieldPolicy* yieldPolicy);
-
- private:
- /**
- * Passes stats from the trial period run of the cached plan to the plan cache.
- *
- * If the plan cache entry is deleted before we get a chance to update it, then this
- * is a no-op.
- */
- void updatePlanCache();
-
- /**
- * Uses the QueryPlanner and the MultiPlanStage to re-generate candidate plans for this
- * query and select a new winner.
- *
- * We fallback to a new plan if updatePlanCache() tells us that the performance was worse
- * than anticipated during the trial period.
- *
- * We only write the result of re-planning to the plan cache if 'shouldCache' is true.
- */
- Status replan(PlanYieldPolicy* yieldPolicy, bool shouldCache);
-
- /**
- * May yield during the cached plan stage's trial period or replanning phases.
- *
- * Returns a non-OK status if the plan was killed during a yield.
- */
- Status tryYield(PlanYieldPolicy* yieldPolicy);
-
- // Not owned.
- OperationContext* _txn;
-
- // Not owned. Must be non-null.
- Collection* _collection;
-
- // Not owned.
- WorkingSet* _ws;
-
- // Not owned.
- CanonicalQuery* _canonicalQuery;
-
- QueryPlannerParams _plannerParams;
-
- // The number of work cycles taken to decide on a winning plan when the plan was first
- // cached.
- size_t _decisionWorks;
-
- // If we fall back to re-planning the query, and there is just one resulting query solution,
- // that solution is owned here.
- std::unique_ptr<QuerySolution> _replannedQs;
-
- std::unique_ptr<PlanStage> _root;
-
- // Any results produced during trial period execution are kept here.
- std::list<WorkingSetID> _results;
-
- // When a stage requests a yield for document fetch, it gives us back a RecordFetcher*
- // to use to pull the record into memory. We take ownership of the RecordFetcher here,
- // deleting it after we've had a chance to do the fetch. For timing-based yields, we
- // just pass a NULL fetcher.
- std::unique_ptr<RecordFetcher> _fetcher;
-
- // Stats
- CommonStats _commonStats;
- CachedPlanStats _specificStats;
- };
+ void updatePlanCache();
+
+ /**
+ * Uses the QueryPlanner and the MultiPlanStage to re-generate candidate plans for this
+ * query and select a new winner.
+ *
+ * We fallback to a new plan if updatePlanCache() tells us that the performance was worse
+ * than anticipated during the trial period.
+ *
+ * We only write the result of re-planning to the plan cache if 'shouldCache' is true.
+ */
+ Status replan(PlanYieldPolicy* yieldPolicy, bool shouldCache);
+
+ /**
+ * May yield during the cached plan stage's trial period or replanning phases.
+ *
+ * Returns a non-OK status if the plan was killed during a yield.
+ */
+ Status tryYield(PlanYieldPolicy* yieldPolicy);
+
+ // Not owned.
+ OperationContext* _txn;
+
+ // Not owned. Must be non-null.
+ Collection* _collection;
+
+ // Not owned.
+ WorkingSet* _ws;
+
+ // Not owned.
+ CanonicalQuery* _canonicalQuery;
+
+ QueryPlannerParams _plannerParams;
+
+ // The number of work cycles taken to decide on a winning plan when the plan was first
+ // cached.
+ size_t _decisionWorks;
+
+ // If we fall back to re-planning the query, and there is just one resulting query solution,
+ // that solution is owned here.
+ std::unique_ptr<QuerySolution> _replannedQs;
+
+ std::unique_ptr<PlanStage> _root;
+
+ // Any results produced during trial period execution are kept here.
+ std::list<WorkingSetID> _results;
+
+ // When a stage requests a yield for document fetch, it gives us back a RecordFetcher*
+ // to use to pull the record into memory. We take ownership of the RecordFetcher here,
+ // deleting it after we've had a chance to do the fetch. For timing-based yields, we
+ // just pass a NULL fetcher.
+ std::unique_ptr<RecordFetcher> _fetcher;
+
+ // Stats
+ CommonStats _commonStats;
+ CachedPlanStats _specificStats;
+};
} // namespace mongo