0
0
mirror of https://github.com/mongodb/mongo.git synced 2024-11-30 00:56:44 +01:00

Recording plan configurable

This commit is contained in:
Aaron 2009-02-24 18:23:11 -05:00
parent 0d8dded1c3
commit b1341cf000
4 changed files with 10 additions and 3 deletions

View File

@ -697,6 +697,7 @@ namespace mongo {
return new CountOp( spec_ );
}
int count() const { return count_; }
virtual bool mayRecordPlan() const { return true; }
private:
BSONObj spec_;
int count_;
@ -838,6 +839,7 @@ namespace mongo {
}
setComplete();
}
virtual bool mayRecordPlan() const { return ntoreturn_ != 1; }
virtual QueryOp *clone() const {
return new DoQueryOp( ntoskip_, ntoreturn_, order_, wantMore_, explain_, filter_, queryOptions_ );
}

View File

@ -257,7 +257,8 @@ namespace mongo {
op.setExceptionMessage( "Caught unknown exception" );
}
if ( op.complete() ) {
op.qp().registerSelf();
if ( op.mayRecordPlan() )
op.qp().registerSelf();
return *i;
}
if ( op.error() )

View File

@ -74,19 +74,20 @@ namespace mongo {
virtual ~QueryOp() {}
virtual void init() = 0;
virtual void next() = 0;
void setQueryPlan( const QueryPlan *qp ) { qp_ = qp; }
virtual bool mayRecordPlan() const = 0;
// Return a copy of the inheriting class, which will be run with its own
// query plan.
virtual QueryOp *clone() const = 0;
bool complete() const { return complete_; }
bool error() const { return error_; }
string exceptionMessage() const { return exceptionMessage_; }
const QueryPlan &qp() { return *qp_; }
// To be called by QueryPlanSet::Runner only.
void setQueryPlan( const QueryPlan *qp ) { qp_ = qp; }
void setExceptionMessage( const string &exceptionMessage ) {
error_ = true;
exceptionMessage_ = exceptionMessage;
}
const QueryPlan &qp() { return *qp_; }
protected:
void setComplete() { complete_ = true; }
private:

View File

@ -664,6 +664,7 @@ namespace QueryOptimizerTests {
youThrow_ = !youThrow_;
return op;
}
virtual bool mayRecordPlan() const { return true; }
private:
bool iThrow_;
bool &threw_;
@ -695,6 +696,7 @@ namespace QueryOptimizerTests {
virtual QueryOp *clone() const {
return new TestOp();
}
virtual bool mayRecordPlan() const { return true; }
};
};
@ -744,6 +746,7 @@ namespace QueryOptimizerTests {
virtual QueryOp *clone() const {
return new TestOp();
}
virtual bool mayRecordPlan() const { return true; }
};
};