mirror of
https://github.com/mongodb/mongo.git
synced 2024-11-30 00:56:44 +01:00
Support large count and nscanned
This commit is contained in:
parent
ca46791a7b
commit
c27e290116
@ -571,8 +571,8 @@ namespace mongo {
|
||||
virtual bool run(const char *_ns, BSONObj& cmdObj, string& errmsg, BSONObjBuilder& result, bool) {
|
||||
string ns = database->name + '.' + cmdObj.findElement(name).valuestr();
|
||||
string err;
|
||||
int n = runCount(ns.c_str(), cmdObj, err);
|
||||
int nn = n;
|
||||
long long n = runCount(ns.c_str(), cmdObj, err);
|
||||
long long nn = n;
|
||||
bool ok = true;
|
||||
if ( n < 0 ) {
|
||||
ok = false;
|
||||
|
@ -353,7 +353,7 @@ namespace mongo {
|
||||
set<string> allIndexKeys;
|
||||
void computeIndexKeys();
|
||||
int writeCount_;
|
||||
map< QueryPattern, pair< BSONObj, int > > queryCache_;
|
||||
map< QueryPattern, pair< BSONObj, long long > > queryCache_;
|
||||
string logNS_;
|
||||
bool logValid_;
|
||||
public:
|
||||
@ -387,10 +387,10 @@ namespace mongo {
|
||||
BSONObj indexForPattern( const QueryPattern &pattern ) {
|
||||
return queryCache_[ pattern ].first;
|
||||
}
|
||||
int nScannedForPattern( const QueryPattern &pattern ) {
|
||||
long long nScannedForPattern( const QueryPattern &pattern ) {
|
||||
return queryCache_[ pattern ].second;
|
||||
}
|
||||
void registerIndexForPattern( const QueryPattern &pattern, const BSONObj &indexKey, int nScanned ) {
|
||||
void registerIndexForPattern( const QueryPattern &pattern, const BSONObj &indexKey, long long nScanned ) {
|
||||
queryCache_[ pattern ] = make_pair( indexKey, nScanned );
|
||||
}
|
||||
|
||||
|
20
db/query.cpp
20
db/query.cpp
@ -96,7 +96,7 @@ namespace mongo {
|
||||
bool justOne_;
|
||||
int count_;
|
||||
int &bestCount_;
|
||||
int nScanned_;
|
||||
long long nScanned_;
|
||||
auto_ptr< Cursor > c_;
|
||||
auto_ptr< KeyValJSMatcher > matcher_;
|
||||
};
|
||||
@ -369,10 +369,10 @@ namespace mongo {
|
||||
return new UpdateOp();
|
||||
}
|
||||
auto_ptr< Cursor > c() { return c_; }
|
||||
int nscanned() const { return nscanned_; }
|
||||
long long nscanned() const { return nscanned_; }
|
||||
private:
|
||||
auto_ptr< Cursor > c_;
|
||||
int nscanned_;
|
||||
long long nscanned_;
|
||||
auto_ptr< KeyValJSMatcher > matcher_;
|
||||
};
|
||||
|
||||
@ -708,11 +708,11 @@ namespace mongo {
|
||||
virtual QueryOp *clone() const {
|
||||
return new CountOp( spec_ );
|
||||
}
|
||||
int count() const { return count_; }
|
||||
long long count() const { return count_; }
|
||||
virtual bool mayRecordPlan() const { return true; }
|
||||
private:
|
||||
BSONObj spec_;
|
||||
int count_;
|
||||
long long count_;
|
||||
auto_ptr< Cursor > c_;
|
||||
BSONObj query_;
|
||||
set< string > fields_;
|
||||
@ -724,7 +724,7 @@ namespace mongo {
|
||||
/* { count: "collectionname"[, query: <query>] }
|
||||
returns -1 on ns does not exist error.
|
||||
*/
|
||||
int runCount( const char *ns, const BSONObj &cmd, string &err ) {
|
||||
long long runCount( const char *ns, const BSONObj &cmd, string &err ) {
|
||||
NamespaceDetails *d = nsdetails( ns );
|
||||
if ( !d ) {
|
||||
err = "ns missing";
|
||||
@ -882,7 +882,7 @@ namespace mongo {
|
||||
auto_ptr< Cursor > cursor() { return c_; }
|
||||
auto_ptr< KeyValJSMatcher > matcher() { return matcher_; }
|
||||
int n() const { return n_; }
|
||||
int nscanned() const { return nscanned_; }
|
||||
long long nscanned() const { return nscanned_; }
|
||||
bool saveClientCursor() const { return saveClientCursor_; }
|
||||
private:
|
||||
BufBuilder b_;
|
||||
@ -894,7 +894,7 @@ namespace mongo {
|
||||
set< string > *filter_;
|
||||
bool ordering_;
|
||||
auto_ptr< Cursor > c_;
|
||||
int nscanned_;
|
||||
long long nscanned_;
|
||||
int queryOptions_;
|
||||
auto_ptr< KeyValJSMatcher > matcher_;
|
||||
int n_;
|
||||
@ -918,7 +918,7 @@ namespace mongo {
|
||||
|
||||
log(2) << "runQuery: " << ns << jsobj << endl;
|
||||
|
||||
int nscanned = 0;
|
||||
long long nscanned = 0;
|
||||
bool wantMore = true;
|
||||
int ntoreturn = _ntoreturn;
|
||||
if ( _ntoreturn < 0 ) {
|
||||
@ -1041,7 +1041,7 @@ namespace mongo {
|
||||
builder.append("cursor", c->toString());
|
||||
builder.append("startKey", c->prettyStartKey());
|
||||
builder.append("endKey", c->prettyEndKey());
|
||||
builder.append("nscanned", dqo.nscanned());
|
||||
builder.append("nscanned", double( dqo.nscanned() ) );
|
||||
builder.append("n", n);
|
||||
if ( dqo.scanAndOrderRequired() )
|
||||
builder.append("scanAndOrder", true);
|
||||
|
@ -77,7 +77,7 @@ namespace mongo {
|
||||
// If justOne is true, deletedId is set to the id of the deleted object.
|
||||
int deleteObjects(const char *ns, BSONObj pattern, bool justOne, BSONObj *deletedId = 0, bool god=false);
|
||||
|
||||
int runCount(const char *ns, const BSONObj& cmd, string& err);
|
||||
long long runCount(const char *ns, const BSONObj& cmd, string& err);
|
||||
|
||||
auto_ptr< QueryResult > runQuery(Message& m, stringstream& ss );
|
||||
|
||||
|
@ -155,7 +155,7 @@ namespace mongo {
|
||||
return index_->keyPattern();
|
||||
}
|
||||
|
||||
void QueryPlan::registerSelf( int nScanned ) const {
|
||||
void QueryPlan::registerSelf( long long nScanned ) const {
|
||||
NamespaceDetailsTransient::get( ns() ).registerIndexForPattern( fbs_.pattern( order_ ), indexKey(), nScanned );
|
||||
}
|
||||
|
||||
@ -322,8 +322,8 @@ namespace mongo {
|
||||
return *i;
|
||||
}
|
||||
|
||||
int nScanned = 0;
|
||||
int nScannedBackup = 0;
|
||||
long long nScanned = 0;
|
||||
long long nScannedBackup = 0;
|
||||
while( 1 ) {
|
||||
++nScanned;
|
||||
unsigned errCount = 0;
|
||||
|
@ -51,7 +51,7 @@ namespace mongo {
|
||||
const char *ns() const { return fbs_.ns(); }
|
||||
BSONObj query() const { return fbs_.query(); }
|
||||
const FieldBound &bound( const char *fieldName ) const { return fbs_.bound( fieldName ); }
|
||||
void registerSelf( int nScanned ) const;
|
||||
void registerSelf( long long nScanned ) const;
|
||||
private:
|
||||
const FieldBoundSet &fbs_;
|
||||
const BSONObj &order_;
|
||||
@ -132,7 +132,7 @@ namespace mongo {
|
||||
bool usingPrerecordedPlan_;
|
||||
BSONObj hint_;
|
||||
BSONObj order_;
|
||||
int oldNScanned_;
|
||||
long long oldNScanned_;
|
||||
bool honorRecordedPlan_;
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user