summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Cahill <michael.cahill@wiredtiger.com>2012-09-13 14:32:42 +1000
committerMichael Cahill <michael.cahill@wiredtiger.com>2012-09-13 14:32:42 +1000
commit25e5d7d4d2c8b4cb4dec77b0251a19150e859af3 (patch)
tree341b5ea39b29bddeae973297268b22e997422ac0
parent024d1fc4a883194f5d435bc410c20f3e18fb73b7 (diff)
downloadmongo-25e5d7d4d2c8b4cb4dec77b0251a19150e859af3.tar.gz
Close Bloom cursors when closing an LSM cursor.
This means using the internal API for opening the cursor in the Bloom tree, so it is ordered correctly in the session list.
-rw-r--r--src/bloom/bloom.c12
-rw-r--r--src/cursor/cur_config.c2
-rw-r--r--src/cursor/cur_index.c2
-rw-r--r--src/include/extern.h1
-rw-r--r--src/lsm/lsm_cursor.c14
-rw-r--r--test/bloom/test_bloom.c5
6 files changed, 16 insertions, 20 deletions
diff --git a/src/bloom/bloom.c b/src/bloom/bloom.c
index f7dfc275d31..657cb56e04b 100644
--- a/src/bloom/bloom.c
+++ b/src/bloom/bloom.c
@@ -112,23 +112,23 @@ __wt_bloom_create(
*/
int
__wt_bloom_open(WT_SESSION_IMPL *session,
- const char *uri, uint32_t factor, uint32_t k, WT_BLOOM **bloomp)
+ const char *uri, uint32_t factor, uint32_t k,
+ WT_CURSOR *owner, WT_BLOOM **bloomp)
{
WT_BLOOM *bloom;
WT_CURSOR *c;
- WT_SESSION *wt_session;
+ const char *cfg[] = API_CONF_DEFAULTS(session, open_cursor, NULL);
uint64_t size;
- wt_session = (WT_SESSION *)session;
-
WT_RET(__bloom_init(session, uri, NULL, &bloom));
/* Find the largest key, to get the size of the filter. */
- WT_RET(wt_session->open_cursor(wt_session, bloom->uri, NULL, NULL, &c));
+ cfg[1] = bloom->config;
+ WT_RET(__wt_curfile_open(session, bloom->uri, owner, cfg, &c));
WT_RET(c->prev(c));
WT_RET(c->get_key(c, &size));
- WT_RET(c->close(c));
+ bloom->c = c;
WT_RET(__bloom_setup(bloom, 0, size, factor, k));
*bloomp = bloom;
diff --git a/src/cursor/cur_config.c b/src/cursor/cur_config.c
index db6660e1ba8..5dd91d33c16 100644
--- a/src/cursor/cur_config.c
+++ b/src/cursor/cur_config.c
@@ -68,7 +68,7 @@ __wt_curconfig_open(WT_SESSION_IMPL *session,
/* __wt_cursor_init is last so we don't have to clean up on error. */
STATIC_ASSERT(offsetof(WT_CURSOR_CONFIG, iface) == 0);
- WT_ERR(__wt_cursor_init(cursor, uri, 0, cfg, cursorp));
+ WT_ERR(__wt_cursor_init(cursor, uri, NULL, cfg, cursorp));
if (0) {
err: __wt_free(session, cconfig);
diff --git a/src/cursor/cur_index.c b/src/cursor/cur_index.c
index 4838c33c9d8..01545c97d2f 100644
--- a/src/cursor/cur_index.c
+++ b/src/cursor/cur_index.c
@@ -435,7 +435,7 @@ __wt_curindex_open(WT_SESSION_IMPL *session,
WT_ERR(__curindex_open_colgroups(session, cindex, cfg));
/* __wt_cursor_init is last so we don't have to clean up on error. */
- WT_ERR(__wt_cursor_init(cursor, cursor->uri, 0, cfg, cursorp));
+ WT_ERR(__wt_cursor_init(cursor, cursor->uri, NULL, cfg, cursorp));
if (0) {
err: (void)__curindex_close(cursor);
diff --git a/src/include/extern.h b/src/include/extern.h
index cc8fd716664..e5ff3de69ab 100644
--- a/src/include/extern.h
+++ b/src/include/extern.h
@@ -234,6 +234,7 @@ extern int __wt_bloom_open(WT_SESSION_IMPL *session,
const char *uri,
uint32_t factor,
uint32_t k,
+ WT_CURSOR *owner,
WT_BLOOM **bloomp);
extern int __wt_bloom_insert(WT_BLOOM *bloom, WT_ITEM *key);
extern int __wt_bloom_finalize(WT_BLOOM *bloom);
diff --git a/src/lsm/lsm_cursor.c b/src/lsm/lsm_cursor.c
index 6e76df3fc7f..ce0a58c51e1 100644
--- a/src/lsm/lsm_cursor.c
+++ b/src/lsm/lsm_cursor.c
@@ -179,10 +179,10 @@ __clsm_open_cursors(WT_CURSOR_LSM *clsm)
WT_ERR(__wt_curfile_open(session,
chunk->uri, &clsm->iface,
F_ISSET(chunk, WT_LSM_CHUNK_ONDISK) ? ckpt_cfg : NULL, cp));
- if (chunk->bloom_uri != NULL)
+ if (chunk->bloom_uri != NULL && !F_ISSET(clsm, WT_CLSM_MERGE))
WT_ERR(__wt_bloom_open(session, chunk->bloom_uri,
lsm_tree->bloom_factor, lsm_tree->bloom_k,
- &clsm->blooms[i]));
+ c, &clsm->blooms[i]));
/* Child cursors always use overwrite and raw mode. */
F_SET(*cp, WT_CURSTD_OVERWRITE | WT_CURSTD_RAW);
@@ -814,10 +814,8 @@ static int
__clsm_close(WT_CURSOR *cursor)
{
WT_CURSOR_LSM *clsm;
- WT_CURSOR *c;
WT_DECL_RET;
WT_SESSION_IMPL *session;
- int i;
/*
* Don't use the normal __clsm_enter path: that is wasted work when
@@ -825,11 +823,7 @@ __clsm_close(WT_CURSOR *cursor)
*/
clsm = (WT_CURSOR_LSM *)cursor;
CURSOR_API_CALL_NOCONF(cursor, session, close, NULL);
- FORALL_CURSORS(clsm, c, i) {
- if (F_ISSET(clsm, WT_CLSM_MERGE))
- printf("LSM merge: closing %s\n", c->uri);
- WT_TRET(c->close(c));
- }
+ WT_TRET(__clsm_close_cursors(clsm));
__wt_free(session, clsm->blooms);
__wt_free(session, clsm->cursors);
/* The WT_LSM_TREE owns the URI. */
@@ -907,7 +901,7 @@ __wt_clsm_open(WT_SESSION_IMPL *session,
clsm->dsk_gen = 0;
STATIC_ASSERT(offsetof(WT_CURSOR_LSM, iface) == 0);
- WT_ERR(__wt_cursor_init(cursor, cursor->uri, 0, cfg, cursorp));
+ WT_ERR(__wt_cursor_init(cursor, cursor->uri, NULL, cfg, cursorp));
/*
* LSM cursors default to overwrite: if no setting was supplied, turn
diff --git a/test/bloom/test_bloom.c b/test/bloom/test_bloom.c
index 0333e7acb53..1b02b958718 100644
--- a/test/bloom/test_bloom.c
+++ b/test/bloom/test_bloom.c
@@ -138,7 +138,7 @@ int run(void)
WT_BLOOM *bloomp;
WT_ITEM item;
WT_SESSION_IMPL *sess;
- const char *uri = "table:my_bloom";
+ const char *uri = "file:my_bloom.bf";
int ret;
uint32_t fp, i;
@@ -171,7 +171,8 @@ int run(void)
die(ret, "__wt_bloom_close");
g.wt_session->checkpoint(g.wt_session, NULL);
- if ((ret = __wt_bloom_open(sess, uri, g.c_factor, g.c_k, &bloomp)) != 0)
+ if ((ret = __wt_bloom_open(
+ sess, uri, g.c_factor, g.c_k, NULL, &bloomp)) != 0)
die(ret, "__wt_bloom_open");
for (i = 0; i < g.c_ops; i++) {
item.data = g.entries[i];