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;
61 return _putBack.size() + batch.nReturned - batch.pos;
63 bool moreInCurrentBatch() {
64 return objsLeftInBatch() > 0;
93 void peek(std::vector<BSONObj>&,
int atMost);
101 bool peekError(
BSONObj* error = NULL);
121 return cursorId == 0;
124 bool tailable()
const {
134 return (resultFlags & flag) != 0;
139 batchSize = newBatchSize;
143 const std::string& _ns,
147 const BSONObj* _fieldsToReturn,
151 const std::string& _ns,
159 long long getCursorId()
const {
170 std::string originalHost()
const {
171 return _originalHost;
174 std::string getns()
const {
178 Message* getMessage() {
179 return batch.m.get();
197 void initLazy(
bool isRetry =
false);
198 bool initLazyFinish(
bool& retry);
202 std::auto_ptr<Message> m;
208 Batch() : m(
new Message()), nReturned(), pos(), data() {}
232 void _finishConsInit();
237 std::auto_ptr<DBClientCursorShim> shim;
241 std::string _originalHost;
250 std::stack<BSONObj> _putBack;
254 std::string _scopedHost;
255 std::string _lazyHost;
258 void dataReceived() {
260 std::string lazyHost;
261 dataReceived(retry, lazyHost);
263 void dataReceived(
bool& retry, std::string& lazyHost);
265 void exhaustReceiveMore();
268 void _assertIfNull()
const {
269 uassert(13348,
"connection died",
this);
273 DBClientCursor(
const DBClientCursor&);
274 DBClientCursor& operator=(
const DBClientCursor&);
277 void _assembleInit(Message& toSend);
285 bool moreInCurrentBatch() {
286 return _c.moreInCurrentBatch();
289 massert(13383,
"BatchIterator empty", moreInCurrentBatch());
291 return _c.nextSafe();
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:138
DB "commands" Basically just invocations of connection.
Definition: dbclientinterface.h:771
Definition: message.h:305
Utility functions for parsing numbers from strings.
Definition: compare_numbers.h:20
void putBack(const BSONObj &o)
restore an object previously returned by next() to the cursor
Definition: dbclientcursor.h:81
Definition: dbclientcursor.h:200
Queries return a cursor object.
Definition: dbclientcursor.h:49
bool isDead() const
cursor no longer valid – use with tailable cursors.
Definition: dbclientcursor.h:120
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:1716
int itcount()
iterate the rest of the cursor and return the number if items
Definition: dbclientcursor.h:106
void decouple()
by default we "own" the cursor and will send the server a KillCursor message when ~DBClientCursor() i...
Definition: dbclientcursor.h:166
Core MongoDB C++ driver interfaces are defined here.
iterate over objects in current batch only - will not cause a network call
Definition: dbclientcursor.h:282
bool hasResultFlag(int flag)
see ResultFlagType (constants.h) for flag values mostly these flags are for internal purposes - Resul...
Definition: dbclientcursor.h:132
abstract class that implements the core db operations
Definition: dbclientinterface.h:1422
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