2009-02-25 06:57:31 +01:00
|
|
|
// cursors.h
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2009-02-25 21:56:15 +01:00
|
|
|
#include "../stdafx.h"
|
2009-02-25 06:57:31 +01:00
|
|
|
|
|
|
|
#include "../db/jsobj.h"
|
|
|
|
#include "../db/dbmessage.h"
|
|
|
|
#include "../client/dbclient.h"
|
2009-11-03 16:35:48 +01:00
|
|
|
#include "../client/parallel.h"
|
2009-02-25 06:57:31 +01:00
|
|
|
|
|
|
|
#include "request.h"
|
|
|
|
|
|
|
|
namespace mongo {
|
|
|
|
|
2009-11-03 16:35:48 +01:00
|
|
|
class ShardedClientCursor {
|
2009-02-25 06:57:31 +01:00
|
|
|
public:
|
2009-11-03 16:35:48 +01:00
|
|
|
ShardedClientCursor( QueryMessage& q , ClusteredCursor * cursor );
|
|
|
|
virtual ~ShardedClientCursor();
|
2009-02-25 07:23:58 +01:00
|
|
|
|
|
|
|
long long getId(){ return _id; }
|
2009-02-25 06:57:31 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @return whether there is more data left
|
|
|
|
*/
|
2009-02-25 07:23:58 +01:00
|
|
|
bool sendNextBatch( Request& r ){ return sendNextBatch( r , _ntoreturn ); }
|
|
|
|
bool sendNextBatch( Request& r , int ntoreturn );
|
2009-02-25 06:57:31 +01:00
|
|
|
|
|
|
|
protected:
|
2009-11-03 16:35:48 +01:00
|
|
|
|
|
|
|
ClusteredCursor * _cursor;
|
|
|
|
|
2009-02-25 06:57:31 +01:00
|
|
|
int _skip;
|
|
|
|
int _ntoreturn;
|
|
|
|
|
|
|
|
int _totalSent;
|
2009-02-25 07:23:58 +01:00
|
|
|
bool _done;
|
2009-02-25 06:57:31 +01:00
|
|
|
|
2009-11-03 16:35:48 +01:00
|
|
|
long long _id;
|
2009-02-25 06:57:31 +01:00
|
|
|
};
|
2009-02-25 07:23:58 +01:00
|
|
|
|
|
|
|
class CursorCache {
|
|
|
|
public:
|
|
|
|
CursorCache();
|
|
|
|
~CursorCache();
|
|
|
|
|
2009-11-03 16:35:48 +01:00
|
|
|
ShardedClientCursor * get( long long id );
|
|
|
|
void store( ShardedClientCursor* cursor );
|
2009-02-25 07:23:58 +01:00
|
|
|
void remove( long long id );
|
|
|
|
|
|
|
|
private:
|
2009-11-03 16:35:48 +01:00
|
|
|
map<long long,ShardedClientCursor*> _cursors;
|
2009-02-25 07:23:58 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
extern CursorCache cursorCache;
|
2009-02-25 06:57:31 +01:00
|
|
|
}
|