diff options
author | Eliot Horowitz <eliot@10gen.com> | 2009-04-22 15:56:23 -0400 |
---|---|---|
committer | Eliot Horowitz <eliot@10gen.com> | 2009-04-22 15:56:23 -0400 |
commit | 676fb4ea3cff94e5e24dddbef46113e04f452a02 (patch) | |
tree | f8a5d8545fed0ea1645cb2726059d38d3c135ac0 /s | |
parent | 56959de5b052775137d410216ad40a52452af38c (diff) | |
download | mongo-676fb4ea3cff94e5e24dddbef46113e04f452a02.tar.gz |
Sharding: fix countObjects, some docs MINOR
Diffstat (limited to 's')
-rw-r--r-- | s/shard.cpp | 9 | ||||
-rw-r--r-- | s/shard.h | 7 |
2 files changed, 9 insertions, 7 deletions
diff --git a/s/shard.cpp b/s/shard.cpp index a202fc9e46d..ba347c7c701 100644 --- a/s/shard.cpp +++ b/s/shard.cpp @@ -273,15 +273,12 @@ namespace mongo { long Shard::countObjects(){ ScopedDbConnection conn( getServer() ); + BSONObj result; - uassert( "datasize failed!" , conn->runCommand( "admin" , BSON( "datasize" << _ns - << "keyPattern" << _manager->getShardKey().key() - << "min" << getMin() - << "max" << getMax() - ) , result ) ); + unsigned long long n = conn->count( _ns , getFilter() ); conn.done(); - return (long)result["numObjects"].number(); + return (long)n; } bool Shard::operator==( const Shard& s ){ diff --git a/s/shard.h b/s/shard.h index 09ca136b56b..800004ff685 100644 --- a/s/shard.h +++ b/s/shard.h @@ -36,10 +36,13 @@ namespace mongo { class ShardObjUnitTest; typedef unsigned long long ServerShardVersion; - + /** config.shard { ns : "alleyinsider.fs.chunks" , min : {} , max : {} , server : "localhost:30001" } + + x is in a shard iff + min <= x < max */ class Shard : public Model , boost::noncopyable { public: @@ -70,6 +73,8 @@ namespace mongo { } void getFilter( BSONObjBuilder& b ); + BSONObj getFilter(){ BSONObjBuilder b; getFilter( b ); return b.obj(); } + BSONObj pickSplitPoint(); Shard * split(); |