summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHari Khalsa <hkhalsa@10gen.com>2014-04-09 13:34:35 -0400
committerMatt Kangas <matt.kangas@mongodb.com>2014-04-10 11:48:15 -0400
commita280cb5a78e94229598c3a540a933e18037dbf5c (patch)
treea8631f6a91561fd88989a43a6690878ec79f1ca1
parentf5544e542d72c990fe4a3588ad632dd3acefe40b (diff)
downloadmongo-a280cb5a78e94229598c3a540a933e18037dbf5c.tar.gz
SERVER-13489 move possible disk access out of index cursor ctor
(cherry picked from commit ae2dc0a937cd66c249d0d98802fe8229e1a32df8)
-rw-r--r--src/mongo/db/index/btree_based_access_method.cpp2
-rw-r--r--src/mongo/db/index/btree_index_cursor.cpp3
-rw-r--r--src/mongo/db/index/btree_index_cursor.h14
3 files changed, 15 insertions, 4 deletions
diff --git a/src/mongo/db/index/btree_based_access_method.cpp b/src/mongo/db/index/btree_based_access_method.cpp
index 729d1226be0..9b7ed5effd1 100644
--- a/src/mongo/db/index/btree_based_access_method.cpp
+++ b/src/mongo/db/index/btree_based_access_method.cpp
@@ -138,7 +138,7 @@ namespace mongo {
}
Status BtreeBasedAccessMethod::newCursor(IndexCursor **out) const {
- *out = new BtreeIndexCursor(_btreeState, _interface);
+ *out = new BtreeIndexCursor(_btreeState, _btreeState->head(), _interface);
return Status::OK();
}
diff --git a/src/mongo/db/index/btree_index_cursor.cpp b/src/mongo/db/index/btree_index_cursor.cpp
index 24b788f7f14..be1472241f3 100644
--- a/src/mongo/db/index/btree_index_cursor.cpp
+++ b/src/mongo/db/index/btree_index_cursor.cpp
@@ -44,11 +44,12 @@ namespace mongo {
// Go forward by default.
BtreeIndexCursor::BtreeIndexCursor(const IndexCatalogEntry* btreeState,
+ const DiskLoc head,
BtreeInterface *interface)
: _direction(1),
_btreeState(btreeState),
_interface(interface),
- _bucket(btreeState->head()),
+ _bucket(head),
_keyOffset(0) {
SimpleMutex::scoped_lock lock(_activeCursorsMutex);
diff --git a/src/mongo/db/index/btree_index_cursor.h b/src/mongo/db/index/btree_index_cursor.h
index 00be494f7ca..73a7923095e 100644
--- a/src/mongo/db/index/btree_index_cursor.h
+++ b/src/mongo/db/index/btree_index_cursor.h
@@ -95,8 +95,18 @@ namespace mongo {
static unordered_set<BtreeIndexCursor*> _activeCursors;
static SimpleMutex _activeCursorsMutex;
- // Go forward by default.
- BtreeIndexCursor(const IndexCatalogEntry* btreeState, BtreeInterface *interface);
+ /**
+ * btreeState is the ICE of the Btree that we're going to traverse.
+ * head is the head of the Btree.
+ * interface is an abstraction to hide the fact that we have two types of Btrees.
+ *
+ * Go forward by default.
+ *
+ * Intentionally private, we're friends with the only class allowed to call it.
+ */
+ BtreeIndexCursor(const IndexCatalogEntry* btreeState,
+ const DiskLoc head,
+ BtreeInterface *interface);
void skipUnusedKeys();