23 #include "mongo/client/export_macros.h"
25 #include "mongo/db/json.h"
26 #include "mongo/util/net/message.h"
30 class DBClientCursorShim;
31 class DBClientCursorShimCursorID;
32 class DBClientCursorShimArray;
33 class DBClientCursorShimTransform;
41 virtual bool more() = 0;
59 int objsLeftInBatch()
const { _assertIfNull();
return _putBack.size() + batch.nReturned - batch.pos; }
60 bool moreInCurrentBatch() {
return objsLeftInBatch() > 0; }
86 void peek(std::vector<BSONObj>&,
int atMost);
94 bool peekError(
BSONObj* error = NULL);
113 bool isDead()
const {
return cursorId == 0; }
123 return (resultFlags & flag) != 0;
130 int _nToSkip,
const BSONObj *_fieldsToReturn,
int queryOptions ,
int bs );
131 DBClientCursor(
DBClientBase* client,
const std::string &_ns,
long long _cursorId,
int _nToReturn,
int options,
int _batchSize );
135 long long getCursorId()
const {
return cursorId; }
142 std::string originalHost()
const {
return _originalHost; }
144 std::string getns()
const {
return ns; }
146 Message* getMessage(){
return batch.m.get(); }
163 void initLazy(
bool isRetry =
false );
164 bool initLazyFinish(
bool& retry );
168 std::auto_ptr<Message> m;
173 Batch() : m(
new Message() ), nReturned(), pos(), data() { }
185 void _finishConsInit();
190 std::auto_ptr<DBClientCursorShim> shim;
194 std::string _originalHost;
203 std::stack< BSONObj > _putBack;
207 std::string _scopedHost;
208 std::string _lazyHost;
211 void dataReceived() {
bool retry; std::string lazyHost; dataReceived( retry, lazyHost ); }
212 void dataReceived(
bool& retry, std::string& lazyHost );
214 void exhaustReceiveMore();
217 void _assertIfNull()
const { uassert(13348,
"connection died",
this); }
220 DBClientCursor(
const DBClientCursor& );
221 DBClientCursor& operator=(
const DBClientCursor& );
224 void _assembleInit( Message& toSend );
232 bool moreInCurrentBatch() {
return _c.moreInCurrentBatch(); }
234 massert( 13383,
"BatchIterator empty", moreInCurrentBatch() );
236 return _c.nextSafe();
238 int n()
const {
return _n; }
DBClientCursorShimCursorID implements the shim interface over a cursor reply document, rather than the traditional OP_REPLY.
Definition: dbclientcursorshimcursorid.h:29
void setBatchSize(int newBatchSize)
Change batchSize after construction. Can change after requesting first batch.
Definition: dbclientcursor.h:127
DB "commands" Basically just invocations of connection.
Definition: dbclientinterface.h:662
Definition: message.h:298
the main MongoDB namespace
Definition: bulk_operation_builder.h:24
void putBack(const BSONObj &o)
restore an object previously returned by next() to the cursor
Definition: dbclientcursor.h:76
Definition: dbclientcursor.h:166
Queries return a cursor object.
Definition: dbclientcursor.h:49
bool isDead() const
cursor no longer valid – use with tailable cursors.
Definition: dbclientcursor.h:113
BSONObj getOwned() const
assure the data buffer is under the control of this BSONObj and not a remote buffer ...
int objsLeftInBatch() const
If true, there is more in our local buffers to be fetched via next().
Definition: dbclientcursor.h:59
for mock purposes only – do not create variants of DBClientCursor, nor hang code here ...
Definition: dbclientcursor.h:38
A basic connection to the database.
Definition: dbclientinterface.h:1551
int itcount()
iterate the rest of the cursor and return the number if items
Definition: dbclientcursor.h:99
void decouple()
by default we "own" the cursor and will send the server a KillCursor message when ~DBClientCursor() i...
Definition: dbclientcursor.h:140
Core MongoDB C++ driver interfaces are defined here.
iterate over objects in current batch only - will not cause a network call
Definition: dbclientcursor.h:229
bool hasResultFlag(int flag)
see ResultFlagType (constants.h) for flag values mostly these flags are for internal purposes - Resul...
Definition: dbclientcursor.h:121
abstract class that implements the core db operations
Definition: dbclientinterface.h:1330
DBClientCursorShimArray implements the shim interface over an array of bson obj's.
Definition: dbclientcursorshimarray.h:28
C++ representation of a "BSON" object – that is, an extended JSON-style object in a binary represent...
Definition: bsonobj.h:78
QueryOption_CursorTailable
Tailable means cursor is not closed when the last data is retrieved.
Definition: dbclientinterface.h:55