diff options
author | Tyler Brock <tyler.brock@gmail.com> | 2014-12-19 11:21:57 -0500 |
---|---|---|
committer | Tyler Brock <tyler.brock@gmail.com> | 2015-01-15 10:28:30 -0500 |
commit | cdd91e98657c7f0ff792a6eeca7c8c80503d3b77 (patch) | |
tree | 346d67604aac747b520787027c72d14251ddf448 /src | |
parent | 2e547413832ebd20bf25f1af4827d315867ee71c (diff) | |
download | mongo-cdd91e98657c7f0ff792a6eeca7c8c80503d3b77.tar.gz |
SERVER-16658 multibatch getIndexSpecs/getCollectionInfos
Diffstat (limited to 'src')
-rw-r--r-- | src/mongo/client/dbclient.cpp | 34 |
1 files changed, 22 insertions, 12 deletions
diff --git a/src/mongo/client/dbclient.cpp b/src/mongo/client/dbclient.cpp index eab1f5c9877..f9b6e05247b 100644 --- a/src/mongo/client/dbclient.cpp +++ b/src/mongo/client/dbclient.cpp @@ -908,10 +908,6 @@ namespace mongo { // TODO(spencer): remove fallback behavior after 2.8 { - // TODO: This implementation only reads the first batch of results from the - // listCollections command, and masserts if there are multiple batches to read. A - // correct implementation needs to instantiate a command cursor from the command - // response object, and use it to read in all of the command results. BSONObj res; if (runCommand(db, BSON("listCollections" << 1 << "filter" << filter @@ -919,14 +915,23 @@ namespace mongo { res, QueryOption_SlaveOk)) { BSONObj cursorObj = res["cursor"].Obj(); - massert(28586, "reading multiple batches from listCollections not implemented", - cursorObj["id"].numberInt() == 0); BSONObj collections = cursorObj["firstBatch"].Obj(); BSONObjIterator it( collections ); while ( it.more() ) { BSONElement e = it.next(); infos.push_back( e.Obj().getOwned() ); } + + const long long id = cursorObj["id"].Long(); + + if ( id != 0 ) { + const std::string ns = cursorObj["ns"].String(); + auto_ptr<DBClientCursor> cursor = getMore(ns, id, 0, 0); + while ( cursor->more() ) { + infos.push_back(cursor->nextSafe().getOwned()); + } + } + return infos; } @@ -1362,10 +1367,6 @@ namespace mongo { list<BSONObj> specs; { - // TODO: This implementation only reads the first batch of results from the - // listIndexes command, and masserts if there are multiple batches to read. A - // correct implementation needs to instantiate a command cursor from the command - // response object, and use it to read in all of the command results. BSONObj cmd = BSON( "listIndexes" << nsToCollectionSubstring( ns ) << "cursor" << BSONObj() @@ -1374,12 +1375,21 @@ namespace mongo { BSONObj res; if ( runCommand( nsToDatabase( ns ), cmd, res, options ) ) { BSONObj cursorObj = res["cursor"].Obj(); - massert(28587, "reading multiple batches from listIndexes not implemented", - cursorObj["id"].numberInt() == 0); BSONObjIterator i( cursorObj["firstBatch"].Obj() ); while ( i.more() ) { specs.push_back( i.next().Obj().getOwned() ); } + + const long long id = cursorObj["id"].Long(); + + if ( id != 0 ) { + const std::string ns = cursorObj["ns"].String(); + auto_ptr<DBClientCursor> cursor = getMore(ns, id, 0, 0); + while ( cursor->more() ) { + specs.push_back(cursor->nextSafe().getOwned()); + } + } + return specs; } int code = res["code"].numberInt(); |