Skip to content

Commit

Permalink
SERVER-2294 fix nExtents test paramenter handling to satisfy existing…
Browse files Browse the repository at this point in the history
… unit tests
  • Loading branch information
astaple committed Dec 28, 2010
1 parent dccc20d commit 0ee1496
Showing 1 changed file with 24 additions and 27 deletions.
51 changes: 24 additions & 27 deletions db/pdfile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -220,35 +220,32 @@ namespace mongo {
// $nExtents just for debug/testing.
BSONElement e = options.getField( "$nExtents" );
Database *database = cc().database();
if ( !e.eoo() ) {
if ( e.type() == Array ) {
// We create one extent per array entry, with size specified
// by the array value.
BSONObjIterator i( e.embeddedObject() );
while( i.more() ) {
BSONElement e = i.next();
int size = int( e.number() );
assert( size <= 0x7fffffff );
// $nExtents is just for testing - always allocate new extents
// rather than reuse existing extents so we have some predictibility
// in the extent size used by our tests
database->suitableFile( (int) size, false )->createExtent( ns, (int) size, newCapped );
}
} else {
// We create '$nExtents' extents, each of size 'size'.
int nExtents = int( e.number() );
if ( nExtents > 0 ) {
assert( size <= 0x7fffffff );
for ( int i = 0; i < nExtents; ++i ) {
assert( size <= 0x7fffffff );
// $nExtents is just for testing - always allocate new extents
// rather than reuse existing extents so we have some predictibility
// in the extent size used by our tests
database->suitableFile( (int) size, false )->createExtent( ns, (int) size, newCapped );
}
}
if ( e.type() == Array ) {
// We create one extent per array entry, with size specified
// by the array value.
BSONObjIterator i( e.embeddedObject() );
while( i.more() ) {
BSONElement e = i.next();
int size = int( e.number() );
assert( size <= 0x7fffffff );
// $nExtents is just for testing - always allocate new extents
// rather than reuse existing extents so we have some predictibility
// in the extent size used by our tests
database->suitableFile( (int) size, false )->createExtent( ns, (int) size, newCapped );
}
} else if ( int( e.number() ) > 0 ) {
// We create '$nExtents' extents, each of size 'size'.
int nExtents = int( e.number() );
assert( size <= 0x7fffffff );
for ( int i = 0; i < nExtents; ++i ) {
assert( size <= 0x7fffffff );
// $nExtents is just for testing - always allocate new extents
// rather than reuse existing extents so we have some predictibility
// in the extent size used by our tests
database->suitableFile( (int) size, false )->createExtent( ns, (int) size, newCapped );
}
} else {
// This is the non test case, where we don't have a $nExtents spec.
while ( size > 0 ) {
int max = MongoDataFile::maxSize() - DataFileHeader::HeaderSize;
int desiredExtentSize = (int) (size > max ? max : size);
Expand Down

0 comments on commit 0ee1496

Please sign in to comment.