Permalink
Browse files

Promote QueryOptimizerCursor::CandidatePlans to CandidatePlanCharacter.

  • Loading branch information...
1 parent 72e76dd commit c960bff8fc62c81ef55c519fb4d604cb82562706 @astaple astaple committed Apr 3, 2012
@@ -566,7 +566,7 @@ namespace mongo {
bool singlePlan = !_queryOptimizerCursor;
bool singleOrderedPlan =
singlePlan && ( !queryPlan.valid() || !queryPlan._scanAndOrderRequired );
- QueryOptimizerCursor::CandidatePlans queryOptimizerPlans;
+ CandidatePlanCharacter queryOptimizerPlans;
if ( _queryOptimizerCursor ) {
queryOptimizerPlans = _queryOptimizerCursor->initialCandidatePlans();
}
@@ -282,6 +282,26 @@ namespace mongo {
}
};
+ /** Summarizes the candidate plans that may run for a query. */
+ class CandidatePlanCharacter {
+ public:
+ CandidatePlanCharacter( bool mayRunInOrderPlan, bool mayRunOutOfOrderPlan ) :
+ _mayRunInOrderPlan( mayRunInOrderPlan ),
+ _mayRunOutOfOrderPlan( mayRunOutOfOrderPlan ) {
+ }
+ CandidatePlanCharacter() :
+ _mayRunInOrderPlan(),
+ _mayRunOutOfOrderPlan() {
+ }
+ bool mayRunInOrderPlan() const { return _mayRunInOrderPlan; }
+ bool mayRunOutOfOrderPlan() const { return _mayRunOutOfOrderPlan; }
+ bool valid() const { return mayRunInOrderPlan() || mayRunOutOfOrderPlan(); }
+ bool hybridPlanSet() const { return mayRunInOrderPlan() && mayRunOutOfOrderPlan(); }
+ private:
+ bool _mayRunInOrderPlan;
+ bool _mayRunOutOfOrderPlan;
+ };
+
/**
* A set of candidate query plans for a query. This class can return a best guess plan or run a
* QueryOp on all the plans.
@@ -89,27 +89,8 @@ namespace mongo {
class QueryOptimizerCursor : public Cursor {
public:
- /** Summarizes the candidate plans that may run for a query. */
- class CandidatePlans {
- public:
- CandidatePlans( bool mayRunInOrderPlan, bool mayRunOutOfOrderPlan ) :
- _mayRunInOrderPlan( mayRunInOrderPlan ),
- _mayRunOutOfOrderPlan( mayRunOutOfOrderPlan ) {
- }
- CandidatePlans() :
- _mayRunInOrderPlan(),
- _mayRunOutOfOrderPlan() {
- }
- bool mayRunInOrderPlan() const { return _mayRunInOrderPlan; }
- bool mayRunOutOfOrderPlan() const { return _mayRunOutOfOrderPlan; }
- bool valid() const { return mayRunInOrderPlan() || mayRunOutOfOrderPlan(); }
- bool hybridPlanSet() const { return mayRunInOrderPlan() && mayRunOutOfOrderPlan(); }
- private:
- bool _mayRunInOrderPlan;
- bool _mayRunOutOfOrderPlan;
- };
/** Candidate plans for the query before it begins running. */
- virtual CandidatePlans initialCandidatePlans() const = 0;
+ virtual CandidatePlanCharacter initialCandidatePlans() const = 0;
/** FieldRangeSet for the query before it begins running. */
virtual const FieldRangeSet *initialFieldRangeSet() const = 0;
@@ -509,7 +509,7 @@ namespace mongo {
return _currOp->currentMatches( details );
}
- virtual CandidatePlans initialCandidatePlans() const {
+ virtual CandidatePlanCharacter initialCandidatePlans() const {
return _initialCandidatePlans;
}
@@ -661,7 +661,7 @@ namespace mongo {
bool _requireOrder;
auto_ptr<MultiPlanScanner> _mps;
- CandidatePlans _initialCandidatePlans;
+ CandidatePlanCharacter _initialCandidatePlans;
shared_ptr<QueryOptimizerCursorOp> _originalOp;
QueryOptimizerCursorOp *_currOp;
bool _completePlanOfHybridSetScanAndOrderRequired;
@@ -2838,7 +2838,7 @@ namespace QueryOptimizerCursorTests {
protected:
void checkCursor( bool mayRunInOrderPlan, bool mayRunOutOfOrderPlan,
bool runningInitialInOrderPlan, bool possiblyExcludedPlans ) {
- QueryOptimizerCursor::CandidatePlans plans = _cursor->initialCandidatePlans();
+ CandidatePlanCharacter plans = _cursor->initialCandidatePlans();
ASSERT_EQUALS( mayRunInOrderPlan, plans.mayRunInOrderPlan() );
ASSERT_EQUALS( mayRunOutOfOrderPlan, plans.mayRunOutOfOrderPlan() );
ASSERT_EQUALS( runningInitialInOrderPlan, _cursor->runningInitialInOrderPlan() );

0 comments on commit c960bff

Please sign in to comment.