summaryrefslogtreecommitdiff
path: root/db/btreecursor.cpp
diff options
context:
space:
mode:
authorAaron <aaron@10gen.com>2009-09-07 13:19:10 -0700
committerAaron <aaron@10gen.com>2009-09-07 13:19:10 -0700
commitda4030319659ba6fb2bf489d78bcc6f7693188b2 (patch)
tree592825c6482b11ff28edb6704ccac3621f946c5b /db/btreecursor.cpp
parent6840c4e03ad59f648d70baeddf7e9cbaae871d61 (diff)
downloadmongo-da4030319659ba6fb2bf489d78bcc6f7693188b2.tar.gz
SERVER-100 btree cursor handle case where first interval is empty
Diffstat (limited to 'db/btreecursor.cpp')
-rw-r--r--db/btreecursor.cpp23
1 files changed, 12 insertions, 11 deletions
diff --git a/db/btreecursor.cpp b/db/btreecursor.cpp
index 7dd5fc733fa..836268055e0 100644
--- a/db/btreecursor.cpp
+++ b/db/btreecursor.cpp
@@ -53,10 +53,8 @@ namespace mongo {
boundIndex_()
{
assert( !bounds_.empty() );
- startKey = bounds_[ 0 ].first;
- endKey = bounds_[ 0 ].second;
audit();
- init();
+ initInterval();
}
void BtreeCursor::audit() {
@@ -78,10 +76,16 @@ namespace mongo {
bool found;
bucket = indexDetails.head.btree()->
locate(indexDetails, indexDetails.head, startKey, order, keyOfs, found, direction > 0 ? minDiskLoc : maxDiskLoc, direction);
-
skipUnusedKeys();
-
- checkEnd();
+ checkEnd();
+ }
+
+ void BtreeCursor::initInterval() {
+ do {
+ startKey = bounds_[ boundIndex_ ].first;
+ endKey = bounds_[ boundIndex_ ].second;
+ init();
+ } while ( !ok() && ++boundIndex_ < bounds_.size() );
}
/* skip unused keys. */
@@ -127,11 +131,8 @@ namespace mongo {
bucket = bucket.btree()->advance(bucket, keyOfs, direction, "BtreeCursor::advance");
skipUnusedKeys();
checkEnd();
- while( !ok() && ++boundIndex_ < bounds_.size() ) {
- startKey = bounds_[ boundIndex_ ].first;
- endKey = bounds_[ boundIndex_ ].second;
- init();
- }
+ if( !ok() && ++boundIndex_ < bounds_.size() )
+ initInterval();
return !bucket.isNull();
}