summaryrefslogtreecommitdiff
path: root/s
diff options
context:
space:
mode:
authorEliot Horowitz <eliot@10gen.com>2011-03-06 02:51:18 -0500
committerEliot Horowitz <eliot@10gen.com>2011-03-06 20:18:32 -0500
commite521301d18cddf2765a8a392d1ecaccf7e726e20 (patch)
tree4d139e26ea24958f6256483fdd70157b761ba360 /s
parentd2749d18eea3d6a2577b1d6c9a4fed3f45254163 (diff)
downloadmongo-e521301d18cddf2765a8a392d1ecaccf7e726e20.tar.gz
make forcing a split work better SERVER-2419 180?
Diffstat (limited to 's')
-rw-r--r--s/d_split.cpp79
1 files changed, 46 insertions, 33 deletions
diff --git a/s/d_split.cpp b/s/d_split.cpp
index a2e92f9be3e..0896803d1f7 100644
--- a/s/d_split.cpp
+++ b/s/d_split.cpp
@@ -373,47 +373,60 @@ namespace mongo {
// split on the following key.
set<BSONObj> tooFrequentKeys;
splitKeys.push_back( c->currKey().getOwned() );
- while ( cc->ok() ) {
- currCount++;
- BSONObj currKey = c->currKey();
-
- DEV assert( currKey.woCompare( max ) <= 0 );
-
- if ( currCount > keyCount ) {
- // Do not use this split key if it is the same used in the previous split point.
- if ( currKey.woCompare( splitKeys.back() ) == 0 ) {
- tooFrequentKeys.insert( currKey.getOwned() );
+ while ( 1 ) {
+ while ( cc->ok() ) {
+ currCount++;
+ BSONObj currKey = c->currKey();
+
+ DEV assert( currKey.woCompare( max ) <= 0 );
+
+ if ( currCount > keyCount ) {
+ // Do not use this split key if it is the same used in the previous split point.
+ if ( currKey.woCompare( splitKeys.back() ) == 0 ) {
+ tooFrequentKeys.insert( currKey.getOwned() );
+
+ }
+ else {
+ splitKeys.push_back( currKey.getOwned() );
+ currCount = 0;
+ numChunks++;
+
+ LOG(4) << "picked a split key: " << bc->prettyKey( currKey ) << endl;
+ }
}
- else {
- splitKeys.push_back( currKey.getOwned() );
- currCount = 0;
- numChunks++;
-
- LOG(4) << "picked a split key: " << bc->prettyKey( currKey ) << endl;
+
+ cc->advance();
+
+ // Stop if we have enough split points.
+ if ( maxSplitPoints && ( numChunks >= maxSplitPoints ) ) {
+ log() << "max number of requested split points reached (" << numChunks
+ << ") before the end of chunk " << ns << " " << min << " -->> " << max
+ << endl;
+ break;
}
+ if ( ! cc->yieldSometimes() ) {
+ // we were near and and got pushed to the end
+ // i think returning the splits we've already found is fine
+
+ // don't use the btree cursor pointer to acces keys beyond this point but ok
+ // to use it for format the keys we've got already
+
+ break;
+ }
}
-
- cc->advance();
- // Stop if we have enough split points.
- if ( maxSplitPoints && ( numChunks >= maxSplitPoints ) ) {
- log() << "max number of requested split points reached (" << numChunks
- << ") before the end of chunk " << ns << " " << min << " -->> " << max
- << endl;
+ if ( splitKeys.size() > 1 || ! force )
break;
- }
- if ( ! cc->yieldSometimes() ) {
- // we were near and and got pushed to the end
- // i think returning the splits we've already found is fine
-
- // don't use the btree cursor pointer to acces keys beyond this point but ok
- // to use it for format the keys we've got already
-
- break;
- }
+ force = false;
+ keyCount = currCount / 2;
+ 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 ) );
+ cc.reset( new ClientCursor( QueryOption_NoCursorTimeout , c , ns ) );
}
//