diff options
-rw-r--r-- | s/chunk.cpp | 5 | ||||
-rw-r--r-- | s/chunk.h | 5 | ||||
-rw-r--r-- | s/d_split.cpp | 6 |
3 files changed, 10 insertions, 6 deletions
diff --git a/s/chunk.cpp b/s/chunk.cpp index 1c725358c85..b2ad03d9312 100644 --- a/s/chunk.cpp +++ b/s/chunk.cpp @@ -45,6 +45,8 @@ namespace mongo { string Chunk::chunkMetadataNS = "config.chunks"; int Chunk::MaxChunkSize = 1024 * 1024 * 64; + int Chunk::MaxObjectPerChunk = 250000; + Chunk::Chunk( ChunkManager * manager ) : _manager(manager), _lastmod(0) { _setDataWritten(); @@ -182,8 +184,7 @@ namespace mongo { if ( ! force ) { vector<BSONObj> candidates; const int maxPoints = 2; - const int maxObjs = 250000; - pickSplitVector( candidates , getManager()->getCurrentDesiredChunkSize() , maxPoints , maxObjs ); + pickSplitVector( candidates , getManager()->getCurrentDesiredChunkSize() , maxPoints , MaxObjectPerChunk ); if ( candidates.size() <= 1 ) { // no split points means there isn't enough data to split on // 1 split point means we have between half the chunk size to full chunk size diff --git a/s/chunk.h b/s/chunk.h index 43c0d954c65..b4bcc357adc 100644 --- a/s/chunk.h +++ b/s/chunk.h @@ -174,7 +174,7 @@ namespace mongo { static string chunkMetadataNS; static int MaxChunkSize; - + static int MaxObjectPerChunk; // // accessors and helpers // @@ -189,10 +189,11 @@ namespace mongo { const char * getNS() { return "config.chunks"; } Shard getShard() const { return _shard; } const ChunkManager* getManager() const { return _manager; } + private: // main shard info - + ChunkManager * _manager; BSONObj _min; diff --git a/s/d_split.cpp b/s/d_split.cpp index 0896803d1f7..66fe38e5351 100644 --- a/s/d_split.cpp +++ b/s/d_split.cpp @@ -269,7 +269,7 @@ namespace mongo { maxSplitPoints = maxSplitPointsElem.numberLong(); } - long long maxChunkObjects = 0; + long long maxChunkObjects = Chunk::MaxObjectPerChunk; BSONElement MaxChunkObjectsElem = jsobj[ "maxChunkObjects" ]; if ( MaxChunkObjectsElem.isNumber() ) { maxChunkObjects = MaxChunkObjectsElem.numberLong(); @@ -425,7 +425,8 @@ namespace mongo { currCount = 0; log() << "splitVector doing another cycle because of force, keyCount now: " << keyCount << endl; - c.reset( new BtreeCursor( d , d->idxNo(*idx) , *idx , min , max , false , 1 ) ); + bc = new BtreeCursor( d , d->idxNo(*idx) , *idx , min , max , false , 1 ); + c.reset( bc ); cc.reset( new ClientCursor( QueryOption_NoCursorTimeout , c , ns ) ); } @@ -442,6 +443,7 @@ namespace mongo { // Remove the sentinel at the beginning before returning and add fieldnames. splitKeys.erase( splitKeys.begin() ); + assert( c.get() ); for ( vector<BSONObj>::iterator it = splitKeys.begin(); it != splitKeys.end() ; ++it ) { *it = bc->prettyKey( *it ); } |