summaryrefslogtreecommitdiff
path: root/client
diff options
context:
space:
mode:
authorEliot Horowitz <eliot@10gen.com>2010-07-28 16:59:38 -0400
committerEliot Horowitz <eliot@10gen.com>2010-07-28 16:59:38 -0400
commit8740436757ac82673fbcfdf3d38923add03a2948 (patch)
tree9ddd34ca0f78f42781b47afd1d5af889d74ded9e /client
parent861fb36234350bfa137e0c77561887bd401afaa5 (diff)
downloadmongo-8740436757ac82673fbcfdf3d38923add03a2948.tar.gz
fix skip + batch size issue
Diffstat (limited to 'client')
-rw-r--r--client/dbclientcursor.cpp12
-rw-r--r--client/parallel.cpp16
-rw-r--r--client/parallel.h2
3 files changed, 19 insertions, 11 deletions
diff --git a/client/dbclientcursor.cpp b/client/dbclientcursor.cpp
index 4be96a0477b..301955e11c3 100644
--- a/client/dbclientcursor.cpp
+++ b/client/dbclientcursor.cpp
@@ -27,9 +27,15 @@ namespace mongo {
void assembleRequest( const string &ns, BSONObj query, int nToReturn, int nToSkip, const BSONObj *fieldsToReturn, int queryOptions, Message &toSend );
int DBClientCursor::nextBatchSize(){
- if ( nToReturn == 0 )
- return batchSize;
- if ( batchSize == 0 )
+
+ if ( nToReturn == 0 ){
+ if ( batchSize > 1 )
+ return batchSize;
+ else
+ return 0;
+ }
+
+ if ( batchSize <= 1 )
return nToReturn;
return batchSize < nToReturn ? batchSize : nToReturn;
diff --git a/client/parallel.cpp b/client/parallel.cpp
index ab3e21f02e5..7ffec71e63b 100644
--- a/client/parallel.cpp
+++ b/client/parallel.cpp
@@ -54,7 +54,7 @@ namespace mongo {
_done = true; // just in case
}
- auto_ptr<DBClientCursor> ClusteredCursor::query( const string& server , int num , BSONObj extra ){
+ auto_ptr<DBClientCursor> ClusteredCursor::query( const string& server , int num , BSONObj extra , int skipLeft ){
uassert( 10017 , "cursor already done" , ! _done );
BSONObj q = _query;
@@ -71,12 +71,12 @@ namespace mongo {
if ( logLevel >= 5 ){
log(5) << "ClusteredCursor::query (" << type() << ") server:" << server
- << " ns:" << _ns << " query:" << q << " num:" << num <<
- " _fields:" << _fields << " options: " << _options << endl;
+ << " ns:" << _ns << " query:" << q << " num:" << num
+ << " _fields:" << _fields << " options: " << _options << endl;
}
auto_ptr<DBClientCursor> cursor =
- conn->query( _ns , q , num , 0 , ( _fields.isEmpty() ? 0 : &_fields ) , _options , _batchSize );
+ conn->query( _ns , q , num , 0 , ( _fields.isEmpty() ? 0 : &_fields ) , _options , _batchSize == 0 ? 0 : _batchSize + skipLeft );
if ( cursor->hasResultFlag( ResultFlag_ShardConfigStale ) ){
conn.done();
@@ -321,7 +321,7 @@ namespace mongo {
int num = 0;
for ( set<ServerAndQuery>::iterator i = _servers.begin(); i!=_servers.end(); i++ ){
const ServerAndQuery& sq = *i;
- _cursors[num++].reset( query( sq._server , 0 , sq._extra ) );
+ _cursors[num++].reset( query( sq._server , 0 , sq._extra , _needToSkip ) );
}
}
@@ -335,11 +335,13 @@ namespace mongo {
if ( _needToSkip > 0 ){
int n = _needToSkip;
_needToSkip = 0;
-
+
while ( n > 0 && more() ){
- next();
+ BSONObj x = next();
n--;
}
+
+ _needToSkip = n;
}
for ( int i=0; i<_numServers; i++ ){
diff --git a/client/parallel.h b/client/parallel.h
index fb09dd4bb4e..c115b74992f 100644
--- a/client/parallel.h
+++ b/client/parallel.h
@@ -82,7 +82,7 @@ namespace mongo {
virtual BSONObj explain();
protected:
- auto_ptr<DBClientCursor> query( const string& server , int num = 0 , BSONObj extraFilter = BSONObj() );
+ auto_ptr<DBClientCursor> query( const string& server , int num = 0 , BSONObj extraFilter = BSONObj() , int skipLeft = 0 );
BSONObj explain( const string& server , BSONObj extraFilter = BSONObj() );
static BSONObj _concatFilter( const BSONObj& filter , const BSONObj& extraFilter );