mirror of
https://github.com/mongodb/mongo.git
synced 2024-12-01 09:32:32 +01:00
SERVER-109 $or getMore checkpoint
This commit is contained in:
parent
d1c913cc72
commit
68ce7b981e
@ -40,6 +40,7 @@ namespace mongo {
|
||||
class Cursor; /* internal server cursor base class */
|
||||
class ClientCursor;
|
||||
class ParsedQuery;
|
||||
class MultiPlanScanner;
|
||||
|
||||
/* todo: make this map be per connection. this will prevent cursor hijacking security attacks perhaps.
|
||||
*/
|
||||
@ -104,6 +105,7 @@ namespace mongo {
|
||||
/*const*/ CursorId cursorid;
|
||||
string ns;
|
||||
auto_ptr<CoveredIndexMatcher> matcher;
|
||||
auto_ptr< MultiPlanScanner > _mps;
|
||||
shared_ptr<Cursor> c;
|
||||
int pos; // # objects into the cursor so far
|
||||
BSONObj query;
|
||||
|
25
db/query.cpp
25
db/query.cpp
@ -543,7 +543,7 @@ namespace mongo {
|
||||
}
|
||||
|
||||
if ( !_c->ok() ) {
|
||||
finish();
|
||||
finish( false );
|
||||
return;
|
||||
}
|
||||
|
||||
@ -554,7 +554,7 @@ namespace mongo {
|
||||
}
|
||||
|
||||
if ( _pq.getMaxScan() && _nscanned >= _pq.getMaxScan() ){
|
||||
finish();
|
||||
finish( true ); //?
|
||||
return;
|
||||
}
|
||||
|
||||
@ -582,7 +582,7 @@ namespace mongo {
|
||||
_n++;
|
||||
if ( n() >= _pq.getNumToReturn() && !_pq.wantMore() ) {
|
||||
// .limit() was used, show just that much.
|
||||
finish();
|
||||
finish( true ); //?
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -600,7 +600,7 @@ namespace mongo {
|
||||
_n++;
|
||||
if ( ! _c->supportGetMore() ){
|
||||
if ( _pq.enough( n() ) || _buf.len() >= MaxBytesToReturnToClientAtOnce ){
|
||||
finish();
|
||||
finish( true );
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -613,7 +613,7 @@ namespace mongo {
|
||||
_saveClientCursor = true;
|
||||
}
|
||||
}
|
||||
finish();
|
||||
finish( true );
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -624,7 +624,7 @@ namespace mongo {
|
||||
}
|
||||
|
||||
// this plan won, so set data for response broadly
|
||||
void finish() {
|
||||
void finish( bool stop ) {
|
||||
if ( _pq.isExplain() ) {
|
||||
_n = _inMemSort ? _so->size() : _n;
|
||||
}
|
||||
@ -657,7 +657,11 @@ namespace mongo {
|
||||
|
||||
_response.appendData( _buf.buf(), _buf.len() );
|
||||
_buf.decouple();
|
||||
setComplete();
|
||||
if ( stop ) {
|
||||
setStop();
|
||||
} else {
|
||||
setComplete();
|
||||
}
|
||||
}
|
||||
|
||||
virtual bool mayRecordPlan() const { return _pq.getNumToReturn() != 1; }
|
||||
@ -857,18 +861,18 @@ namespace mongo {
|
||||
if ( qps.usingPrerecordedPlan() )
|
||||
oldPlan = qps.explain();
|
||||
}
|
||||
MultiPlanScanner qps( ns, query, order, &hint, !explain, pq.getMin(), pq.getMax() );
|
||||
auto_ptr< MultiPlanScanner > qps( new MultiPlanScanner( ns, query, order, &hint, !explain, pq.getMin(), pq.getMax() ) );
|
||||
BSONObj explainSuffix;
|
||||
if ( explain ) {
|
||||
BSONObjBuilder bb;
|
||||
if ( !oldPlan.isEmpty() )
|
||||
bb.append( "oldPlan", oldPlan.firstElement().embeddedObject().firstElement().embeddedObject() );
|
||||
if ( hint.eoo() )
|
||||
bb.appendElements(qps.explain());
|
||||
bb.appendElements(qps->explain());
|
||||
explainSuffix = bb.obj();
|
||||
}
|
||||
UserQueryOp original( pq, result, explainSuffix, curop );
|
||||
shared_ptr< UserQueryOp > o = qps.runOp( original );
|
||||
shared_ptr< UserQueryOp > o = qps->runOp( original );
|
||||
UserQueryOp &dqo = *o;
|
||||
massert( 10362 , dqo.exceptionMessage(), dqo.complete() );
|
||||
n = dqo.n();
|
||||
@ -884,6 +888,7 @@ namespace mongo {
|
||||
cc->query = jsobj.getOwned();
|
||||
DEV tlog() << " query has more, cursorid: " << cursorid << endl;
|
||||
cc->matcher = dqo.matcher();
|
||||
cc->_mps = qps;
|
||||
cc->pos = n;
|
||||
cc->pq = pq_shared;
|
||||
cc->fields = pq.getFieldPtr();
|
||||
|
@ -51,4 +51,9 @@ t.update( {$or:[{a:2},{b:3}]}, {$set:{z:1}}, false, true );
|
||||
assert.eq.automsg( "3", "t.count( {z:1} )" );
|
||||
|
||||
assert.eq.automsg( "3", "t.find( {$or:[{a:2},{b:3}]} ).toArray().length" );
|
||||
checkArrs( "t.find().toArray()", "t.find( {$or:[{a:2},{b:3}]} ).toArray()" );
|
||||
checkArrs( "t.find().toArray()", "t.find( {$or:[{a:2},{b:3}]} ).toArray()" );
|
||||
|
||||
//t.save( {a:2} );
|
||||
//t.save( {a:2} );
|
||||
|
||||
assert.eq.automsg( "3", "t.find( {$or:[{a:2},{b:3}]} ).batchSize( 2 ).toArray().length" );
|
||||
|
Loading…
Reference in New Issue
Block a user