23#include "mongo/client/export_macros.h"
25#include "mongo/db/json.h"
26#include "mongo/util/net/message.h"
30class DBClientCursorShim;
31class DBClientCursorShimCursorID;
32class DBClientCursorShimArray;
33class 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);
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();
C++ representation of a "BSON" object – that is, an extended JSON-style object in a binary representa...
Definition bsonobj.h:78
BSONObj getOwned() const
assure the data buffer is under the control of this BSONObj and not a remote buffer
abstract class that implements the core db operations
Definition dbclientinterface.h:1422
A basic connection to the database.
Definition dbclientinterface.h:1716
iterate over objects in current batch only - will not cause a network call
Definition dbclientcursor.h:282
for mock purposes only – do not create variants of DBClientCursor, nor hang code here
Definition dbclientcursor.h:38
DBClientCursorShimArray implements the shim interface over an array of bson obj's.
Definition dbclientcursorshimarray.h:28
DBClientCursorShimCursorID implements the shim interface over a cursor reply document,...
Definition dbclientcursorshimcursorid.h:29
Definition dbclientcursor.h:200
Queries return a cursor object.
Definition dbclientcursor.h:49
bool more()
If true, safe to call next().
void setBatchSize(int newBatchSize)
Change batchSize after construction. Can change after requesting first batch.
Definition dbclientcursor.h:138
bool init()
actually does the query
bool hasResultFlag(int flag)
see ResultFlagType (constants.h) for flag values mostly these flags are for internal purposes - Resul...
Definition dbclientcursor.h:132
bool isDead() const
cursor no longer valid – use with tailable cursors.
Definition dbclientcursor.h:120
int itcount()
iterate the rest of the cursor and return the number if items
Definition dbclientcursor.h:106
int objsLeftInBatch() const
If true, there is more in our local buffers to be fetched via next().
Definition dbclientcursor.h:59
void kill()
Marks this object as dead and sends the KillCursors message to the server.
bool initCommand()
Used mainly to run commands on connections that doesn't support lazy initialization and does not supp...
BSONObj nextSafe()
throws AssertionException if get back { $err : ... }
void decouple()
by default we "own" the cursor and will send the server a KillCursor message when ~DBClientCursor() i...
Definition dbclientcursor.h:166
bool peekError(BSONObj *error=NULL)
peek ahead and see if an error occurred, and get the error if so.
void putBack(const BSONObj &o)
restore an object previously returned by next() to the cursor
Definition dbclientcursor.h:81
void peek(std::vector< BSONObj > &, int atMost)
peek ahead at items buffered for future next() calls.
DB "commands" Basically just invocations of connection.
Definition dbclientinterface.h:771
Core MongoDB C++ driver interfaces are defined here.
QueryOption_CursorTailable
Tailable means cursor is not closed when the last data is retrieved.
Definition dbclientinterface.h:55
Utility functions for parsing numbers from strings.
Definition compare_numbers.h:20