0
0
mirror of https://github.com/mongodb/mongo.git synced 2024-11-30 17:10:48 +01:00
mongodb/s/cursors.h

73 lines
1.8 KiB
C
Raw Normal View History

2009-02-25 06:57:31 +01:00
// cursors.h
/*
* Copyright (C) 2010 10gen Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License, version 3,
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
2009-02-25 06:57:31 +01:00
#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
}