summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Cahill <michael.cahill@wiredtiger.com>2012-11-06 16:17:37 +1100
committerMichael Cahill <michael.cahill@wiredtiger.com>2012-11-06 16:17:37 +1100
commitbf6bc01e3fac577d617b016e8b1c429ae94a3020 (patch)
tree83c874394f8823c210fbaf3db44ce3271164b9dc
parenta1359905adb472ff75421f2d15304c4bf705cfff (diff)
downloadmongo-bf6bc01e3fac577d617b016e8b1c429ae94a3020.tar.gz
For update-only LSM cursors, only open a cursor in the primary chunk.
-rw-r--r--src/include/lsm.h1
-rw-r--r--src/lsm/lsm_cursor.c26
2 files changed, 18 insertions, 9 deletions
diff --git a/src/include/lsm.h b/src/include/lsm.h
index 3e4d64ccdb3..96f15991e91 100644
--- a/src/include/lsm.h
+++ b/src/include/lsm.h
@@ -28,6 +28,7 @@ struct __wt_cursor_lsm {
#define WT_CLSM_MINOR_MERGE 0x08 /* Minor merge, include tombstones */
#define WT_CLSM_MULTIPLE 0x10 /* Multiple cursors have values for the
current key */
+#define WT_CLSM_OPEN_READ 0x20 /* Open for reads */
uint32_t flags;
};
diff --git a/src/lsm/lsm_cursor.c b/src/lsm/lsm_cursor.c
index c4cdf43d6f9..21511d20b2a 100644
--- a/src/lsm/lsm_cursor.c
+++ b/src/lsm/lsm_cursor.c
@@ -26,22 +26,23 @@
#define WT_LSM_ENTER(clsm, cursor, session, n) \
clsm = (WT_CURSOR_LSM *)cursor; \
CURSOR_API_CALL(cursor, session, n, NULL); \
- WT_ERR(__clsm_enter(clsm))
+ WT_ERR(__clsm_enter(clsm, 0))
#define WT_LSM_UPDATE_ENTER(clsm, cursor, session, n) \
clsm = (WT_CURSOR_LSM *)cursor; \
CURSOR_UPDATE_API_CALL(cursor, session, n, NULL); \
- WT_ERR(__clsm_enter(clsm))
+ WT_ERR(__clsm_enter(clsm, 1))
-static int __clsm_open_cursors(WT_CURSOR_LSM *, int, uint32_t);
+static int __clsm_open_cursors(WT_CURSOR_LSM *, int, int, uint32_t);
static int __clsm_search(WT_CURSOR *);
static inline int
-__clsm_enter(WT_CURSOR_LSM *clsm)
+__clsm_enter(WT_CURSOR_LSM *clsm, int update)
{
if (!F_ISSET(clsm, WT_CLSM_MERGE) &&
- clsm->dsk_gen != clsm->lsm_tree->dsk_gen)
- WT_RET(__clsm_open_cursors(clsm, 0, 0));
+ (clsm->dsk_gen != clsm->lsm_tree->dsk_gen ||
+ (!update && !F_ISSET(clsm, WT_CLSM_OPEN_READ))))
+ WT_RET(__clsm_open_cursors(clsm, update, 0, 0));
return (0);
}
@@ -106,7 +107,8 @@ __clsm_close_cursors(WT_CURSOR_LSM *clsm)
* Open cursors for the current set of files.
*/
static int
-__clsm_open_cursors(WT_CURSOR_LSM *clsm, int start_chunk, uint32_t start_id)
+__clsm_open_cursors(
+ WT_CURSOR_LSM *clsm, int update, int start_chunk, uint32_t start_id)
{
WT_CURSOR *c, **cp;
WT_DECL_RET;
@@ -124,6 +126,9 @@ __clsm_open_cursors(WT_CURSOR_LSM *clsm, int start_chunk, uint32_t start_id)
c = &clsm->iface;
chunk = NULL;
+ if (!update)
+ F_SET(clsm, WT_CLSM_OPEN_READ);
+
/* Copy the key, so we don't lose the cursor position. */
if (F_ISSET(c, WT_CURSTD_KEY_SET)) {
if (c->key.data != c->key.mem)
@@ -167,6 +172,9 @@ __clsm_open_cursors(WT_CURSOR_LSM *clsm, int start_chunk, uint32_t start_id)
clsm->nchunks = nchunks;
for (i = 0, cp = clsm->cursors; i != clsm->nchunks; i++, cp++) {
+ if (!F_ISSET(clsm, WT_CLSM_OPEN_READ) && i < clsm->nchunks - 1)
+ continue;
+
/*
* Read from the checkpoint if the file has been written.
* Once all cursors switch, the in-memory tree can be evicted.
@@ -229,7 +237,7 @@ __wt_clsm_init_merge(
F_SET(clsm, WT_CLSM_MINOR_MERGE);
clsm->nchunks = nchunks;
- return (__clsm_open_cursors(clsm, start_chunk, start_id));
+ return (__clsm_open_cursors(clsm, 0, start_chunk, start_id));
}
/*
@@ -781,7 +789,7 @@ __clsm_put(
WT_RET(ret);
/* We changed the structure, or someone else did: update. */
- WT_RET(__clsm_enter(clsm));
+ WT_RET(__clsm_enter(clsm, 1));
WT_ASSERT(session, clsm->primary_chunk != NULL);
}