summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/mongo/db/diskloc.h17
-rw-r--r--src/mongo/dbtests/cursortests.cpp26
2 files changed, 40 insertions, 3 deletions
diff --git a/src/mongo/db/diskloc.h b/src/mongo/db/diskloc.h
index e84fcf85583..8682d8d97d4 100644
--- a/src/mongo/db/diskloc.h
+++ b/src/mongo/db/diskloc.h
@@ -48,7 +48,11 @@ namespace mongo {
enum SentinelValues {
/* note NullOfs is different. todo clean up. see refs to NullOfs in code - use is valid but outside DiskLoc context so confusing as-is. */
NullOfs = -1,
- MaxFiles=16000 // thus a limit of about 32TB of data per db
+
+ // Caps the number of files that may be allocated in a database, allowing about 32TB of
+ // data per db. Note that the DiskLoc and DiskLoc56Bit types supports more files than
+ // this value, as does the storage format.
+ MaxFiles=16000
};
DiskLoc(int a, int Ofs) : _a(a), ofs(Ofs) { }
@@ -154,7 +158,14 @@ namespace mongo {
};
#pragma pack()
- const DiskLoc minDiskLoc(0, 1);
- const DiskLoc maxDiskLoc(0x7fffffff, 0x7fffffff);
+ // Minimum allowed DiskLoc. No Record may begin at this location because file and extent
+ // headers must precede Records in a file.
+ const DiskLoc minDiskLoc(0, 0);
+
+ // Maximum allowed DiskLoc. Note that only three bytes are used to represent the file number
+ // for consistency with the v1 index DiskLoc storage format, which uses only 7 bytes total.
+ // No Record may begin at this location because the minimum size of a Record is larger than one
+ // byte.
+ const DiskLoc maxDiskLoc(0x00ffffff, 0x7fffffff);
} // namespace mongo
diff --git a/src/mongo/dbtests/cursortests.cpp b/src/mongo/dbtests/cursortests.cpp
index 747b906049b..14297e6f51e 100644
--- a/src/mongo/dbtests/cursortests.cpp
+++ b/src/mongo/dbtests/cursortests.cpp
@@ -532,6 +532,31 @@ namespace CursorTests {
}
}
};
+
+ /** Test iteration of a reverse direction btree cursor between start and end keys. */
+ class ReverseDirectionStartEndKeys : public Base {
+ public:
+ void run() {
+ _c.dropCollection( ns() );
+ _c.ensureIndex( ns(), BSON( "a" << 1 ) );
+ // Add documents a:4 and a:5
+ _c.insert( ns(), BSON( "a" << 4 ) );
+ _c.insert( ns(), BSON( "a" << 5 ) );
+ Client::ReadContext ctx( ns() );
+ scoped_ptr<Cursor> cursor( BtreeCursor::make( nsdetails( ns() ),
+ nsdetails( ns() )->idx( 1 ),
+ /* startKey */ BSON( "" << 5 ),
+ /* endKey */ BSON( "" << 4 ),
+ /* endKeyInclusive */ true,
+ /* direction */ -1 ) );
+ // Check that the iterator produces the expected results, in the expected order.
+ ASSERT( cursor->ok() );
+ ASSERT_EQUALS( 5, cursor->current()[ "a" ].Int() );
+ ASSERT( cursor->advance() );
+ ASSERT_EQUALS( 4, cursor->current()[ "a" ].Int() );
+ ASSERT( !cursor->advance() );
+ }
+ };
} // namespace BtreeCursor
@@ -769,6 +794,7 @@ namespace CursorTests {
add<BtreeCursor::MatcherRequiredTwoConstraintsDifferentFields>();
add<BtreeCursor::TypeBracketedUpperBoundWithoutMatcher>();
add<BtreeCursor::TypeBracketedLowerBoundWithoutMatcher>();
+ add<BtreeCursor::ReverseDirectionStartEndKeys>();
add<ClientCursor::HandleDelete>();
add<ClientCursor::AboutToDelete>();
add<ClientCursor::AboutToDeleteDuplicate>();