summaryrefslogtreecommitdiff
path: root/src/mongo/db/exec/count.cpp
diff options
context:
space:
mode:
authorMathias Stearn <mathias@10gen.com>2014-06-20 18:58:29 -0400
committerMathias Stearn <mathias@10gen.com>2014-06-20 19:18:00 -0400
commit9176cf37e325074cbf6d76f7d6b0f47ac7c35f4e (patch)
treeef320d79204d64486fc972d6b45b7f861dea6d01 /src/mongo/db/exec/count.cpp
parentc8b2c1c15937b4911ce35c7eabc266330b0f0a1a (diff)
downloadmongo-9176cf37e325074cbf6d76f7d6b0f47ac7c35f4e.tar.gz
SERVER-13635 Clean up BtreeCursor save/restore.
It is now up to the BtreeInterface impl to decide what data it needs to save. Save and restore must *always* be called before/after a yield if you intend to use the cursor again, even if it is at EOF.
Diffstat (limited to 'src/mongo/db/exec/count.cpp')
-rw-r--r--src/mongo/db/exec/count.cpp18
1 files changed, 7 insertions, 11 deletions
diff --git a/src/mongo/db/exec/count.cpp b/src/mongo/db/exec/count.cpp
index 9f2eeaf1a8c..56e8607a611 100644
--- a/src/mongo/db/exec/count.cpp
+++ b/src/mongo/db/exec/count.cpp
@@ -127,20 +127,18 @@ namespace mongo {
}
void Count::prepareToYield() {
- if (isEOF() || (NULL == _btreeCursor.get())) { return; }
+ if (_hitEnd || (NULL == _btreeCursor.get())) { return; }
- verify(!_btreeCursor->isEOF());
_btreeCursor->savePosition();
- if (!_endCursor->isEOF()) {
- _endCursor->savePosition();
- }
+ _endCursor->savePosition();
}
void Count::recoverFromYield() {
- if (isEOF() || (NULL == _btreeCursor.get())) { return; }
+ if (_hitEnd || (NULL == _btreeCursor.get())) { return; }
if (!_btreeCursor->restorePosition().isOK()) {
_hitEnd = true;
+ return;
}
if (_btreeCursor->isEOF()) {
@@ -156,11 +154,9 @@ namespace mongo {
return;
}
- if (!_endCursor->isEOF()) {
- if (!_endCursor->restorePosition().isOK()) {
- _hitEnd = true;
- return;
- }
+ if (!_endCursor->restorePosition().isOK()) {
+ _hitEnd = true;
+ return;
}
// If we were EOF when we yielded we don't always want to have _btreeCursor run until