summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Cahill <michael.cahill@wiredtiger.com>2012-02-02 10:40:54 +1100
committerMichael Cahill <michael.cahill@wiredtiger.com>2012-02-02 10:40:54 +1100
commit09ed40c4dec46311eca052260d1985e14d5d4e83 (patch)
tree7eb96233e2ba8167cc231cd90548111094b1086f
parent1398ddc7e61ca185246a261da7f4614512ddb717 (diff)
downloadmongo-09ed40c4dec46311eca052260d1985e14d5d4e83.tar.gz
Move the stat cursor "clear" config to WT_SESSION::open_cursor.
-rw-r--r--dist/api_data.py7
-rw-r--r--src/config/config_def.c16
-rw-r--r--src/cursor/cur_stat.c23
-rw-r--r--src/include/wiredtiger.in8
4 files changed, 30 insertions, 24 deletions
diff --git a/dist/api_data.py b/dist/api_data.py
index 87e4723aaa0..7629ba0f4e4 100644
--- a/dist/api_data.py
+++ b/dist/api_data.py
@@ -182,9 +182,6 @@ methods = {
'table.meta' : Method(table_meta),
'cursor.close' : Method([
- Config('clear', 'false', r'''
- for statistics cursors, reset statistics counters''',
- type='boolean'),
]),
'session.close' : Method([]),
@@ -215,6 +212,10 @@ methods = {
load path for empty objects, only empty objects may be
bulk-loaded''',
type='boolean'),
+ Config('clear_on_close', 'false', r'''
+ for statistics cursors, reset statistics counters when the cursor is
+ closed''',
+ type='boolean'),
Config('dump', '', r'''
configure the cursor for dump format inputs and outputs:
"hex" selects a simple hexadecimal format, "print"
diff --git a/src/config/config_def.c b/src/config/config_def.c
index 384b7702f1b..69e60a81c76 100644
--- a/src/config/config_def.c
+++ b/src/config/config_def.c
@@ -68,11 +68,11 @@ __wt_confchk_connection_open_session =
const char *
__wt_confdfl_cursor_close =
- "clear=false";
+ "";
const char *
__wt_confchk_cursor_close =
- "clear=(type=boolean)";
+ "";
const char *
__wt_confdfl_file_meta =
@@ -188,15 +188,15 @@ __wt_confchk_session_log_printf =
const char *
__wt_confdfl_session_open_cursor =
- "append=false,bulk=false,dump="",isolation=read-committed,overwrite=false"
- ",raw=false,statistics=false";
+ "append=false,bulk=false,clear_on_close=false,dump="","
+ "isolation=read-committed,overwrite=false,raw=false,statistics=false";
const char *
__wt_confchk_session_open_cursor =
- "append=(type=boolean),bulk=(type=boolean),dump=(choices=[\"hex\","
- "\"print\"]),isolation=(choices=[\"snapshot\",\"read-committed\","
- "\"read-uncommitted\"]),overwrite=(type=boolean),raw=(type=boolean),"
- "statistics=(type=boolean)";
+ "append=(type=boolean),bulk=(type=boolean),clear_on_close=(type=boolean),"
+ "dump=(choices=[\"hex\",\"print\"]),isolation=(choices=[\"snapshot\","
+ "\"read-committed\",\"read-uncommitted\"]),overwrite=(type=boolean),"
+ "raw=(type=boolean),statistics=(type=boolean)";
const char *
__wt_confdfl_session_rename =
diff --git a/src/cursor/cur_stat.c b/src/cursor/cur_stat.c
index 797121847c2..226fc5495fe 100644
--- a/src/cursor/cur_stat.c
+++ b/src/cursor/cur_stat.c
@@ -272,17 +272,16 @@ err: API_END(session);
static int
__curstat_close(WT_CURSOR *cursor, const char *config)
{
- WT_CONFIG_ITEM cval;
WT_CURSOR_STAT *cst;
WT_SESSION_IMPL *session;
int ret;
ret = 0;
CURSOR_API_CALL_CONF(cursor, session, close, NULL, config, cfg);
+ WT_UNUSED(cfg);
cst = (WT_CURSOR_STAT *)cursor;
- WT_TRET(__wt_config_gets(session, cfg, "clear", &cval));
- if (ret == 0 && cval.val != 0 && cst->clear_func)
+ if (ret == 0 && cst->clear_func)
cst->clear_func(cst->stats_first);
__wt_buf_free(session, &cst->pv);
@@ -341,12 +340,19 @@ __wt_curstat_open(WT_SESSION_IMPL *session,
WT_CURSOR *cursor;
WT_STATS *stats_first;
void (*clear_func)(WT_STATS *);
- int raw, ret, stats_count;
+ int clear_on_close, raw, ret, stats_count;
btree = NULL;
+ clear_func = NULL;
cst = NULL;
ret = 0;
+ WT_RET(__wt_config_gets(session, cfg, "clear_on_close", &cval));
+ clear_on_close = (cval.val != 0);
+
+ WT_RET(__wt_config_gets(session, cfg, "raw", &cval));
+ raw = (cval.val != 0);
+
if (!WT_PREFIX_SKIP(uri, "statistics:"))
return (EINVAL);
if (WT_PREFIX_MATCH(uri, "file:")) {
@@ -356,17 +362,16 @@ __wt_curstat_open(WT_SESSION_IMPL *session,
WT_ERR(__wt_btree_stat_init(session));
stats_first = (WT_STATS *)session->btree->stats;
stats_count = sizeof(WT_BTREE_STATS) / sizeof(WT_STATS);
- clear_func = __wt_stat_clear_btree_stats;
+ if (clear_on_close)
+ clear_func = __wt_stat_clear_btree_stats;
} else {
__wt_conn_stat_init(session);
stats_first = (WT_STATS *)S2C(session)->stats;
stats_count = sizeof(WT_CONNECTION_STATS) / sizeof(WT_STATS);
- clear_func = __wt_stat_clear_connection_stats;
+ if (clear_on_close)
+ clear_func = __wt_stat_clear_connection_stats;
}
- WT_ERR(__wt_config_gets(session, cfg, "raw", &cval));
- raw = (cval.val != 0);
-
WT_ERR(__wt_calloc_def(session, 1, &cst));
cst->stats_first = stats_first;
cst->stats_count = stats_count;
diff --git a/src/include/wiredtiger.in b/src/include/wiredtiger.in
index 2baae5a25ea..f932a66ef84 100644
--- a/src/include/wiredtiger.in
+++ b/src/include/wiredtiger.in
@@ -366,10 +366,7 @@ struct __wt_cursor {
* @snippet ex_all.c Close the cursor
*
* @param cursor the cursor handle
- * @configstart{cursor.close, see dist/api_data.py}
- * @config{clear, for statistics cursors\, reset statistics counters.,a
- * boolean flag; default \c false.}
- * @configend
+ * @configempty{cursor.close, see dist/api_data.py}
* @errors
*/
int __F(close)(WT_CURSOR *cursor, const char *config);
@@ -500,6 +497,9 @@ struct __wt_session {
* @config{bulk, configure the cursor for bulk loads; bulk-load is a
* fast load path for empty objects\, only empty objects may be
* bulk-loaded.,a boolean flag; default \c false.}
+ * @config{clear_on_close, for statistics cursors\, reset statistics
+ * counters when the cursor is closed.,a boolean flag; default \c
+ * false.}
* @config{dump, configure the cursor for dump format inputs and
* outputs: "hex" selects a simple hexadecimal format\, "print" selects
* a format where only non-printing characters are hexadecimal encoded.