blob: b1ed4b05c866e2973318e57a9576bbf2e264b5de (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
// cursors.h
#pragma once
#include "../stdafx.h"
#include "../db/jsobj.h"
#include "../db/dbmessage.h"
#include "../client/dbclient.h"
#include "../client/parallel.h"
#include "request.h"
namespace mongo {
class ShardedClientCursor {
public:
ShardedClientCursor( QueryMessage& q , ClusteredCursor * cursor );
virtual ~ShardedClientCursor();
long long getId(){ return _id; }
/**
* @return whether there is more data left
*/
bool sendNextBatch( Request& r ){ return sendNextBatch( r , _ntoreturn ); }
bool sendNextBatch( Request& r , int ntoreturn );
protected:
ClusteredCursor * _cursor;
int _skip;
int _ntoreturn;
int _totalSent;
bool _done;
long long _id;
};
class CursorCache {
public:
CursorCache();
~CursorCache();
ShardedClientCursor * get( long long id );
void store( ShardedClientCursor* cursor );
void remove( long long id );
private:
map<long long,ShardedClientCursor*> _cursors;
};
extern CursorCache cursorCache;
}
|