summaryrefslogtreecommitdiff
path: root/s
diff options
context:
space:
mode:
authorAlberto Lerner <alerner@10gen.com>2010-08-23 19:42:14 -0400
committerAlberto Lerner <alerner@10gen.com>2010-08-23 19:42:14 -0400
commit4bcf64d3d132acaf61580743a5d121bf4d90a002 (patch)
tree1756a5a044720209572057678cf8b76d02217bb7 /s
parent9611d7028316c0d0129f8b52fa7493b76fb370f6 (diff)
downloadmongo-4bcf64d3d132acaf61580743a5d121bf4d90a002.tar.gz
SERVER-1545 Add a fast path to splitVector command.
Diffstat (limited to 's')
-rw-r--r--s/d_split.cpp11
1 files changed, 9 insertions, 2 deletions
diff --git a/s/d_split.cpp b/s/d_split.cpp
index 7ae83849c46..1902596f049 100644
--- a/s/d_split.cpp
+++ b/s/d_split.cpp
@@ -145,14 +145,19 @@ namespace mongo {
return false;
}
+ // If there's not enough data for more than one chunk, no point continuing.
NamespaceDetails *d = nsdetails( ns );
- BtreeCursor c( d , d->idxNo(*idx) , *idx , min , max , false , 1 );
+ const long long dataSize = d->datasize;
+ if ( dataSize < maxChunkSize ) {
+ vector<BSONObj> emptyVector;
+ result.append( "splitKeys" , emptyVector );
+ return true;
+ }
// We'll use the average object size and number of object to find approximately how many keys
// each chunk should have. We'll split a little smaller than the specificied by 'maxSize'
// assuming a recently sharded collectio is still going to grow.
- const long long dataSize = d->datasize;
const long long recCount = d->nrecords;
long long keyCount = 0;
if (( dataSize > 0 ) && ( recCount > 0 )){
@@ -168,6 +173,8 @@ namespace mongo {
long long currCount = 0;
vector<BSONObj> splitKeys;
BSONObj currKey;
+ BtreeCursor c( d , d->idxNo(*idx) , *idx , min , max , false , 1 );
+
while ( c.ok() ){
currCount++;
if ( currCount > keyCount ){