diff options
author | Alex Gorrod <alexg@wiredtiger.com> | 2014-02-25 15:26:09 +1100 |
---|---|---|
committer | Alex Gorrod <alexg@wiredtiger.com> | 2014-02-25 15:26:09 +1100 |
commit | 6647871eecf5ba5df389b96e4f9fbc9cc1ccfdd0 (patch) | |
tree | 00e7d10c7a5fb85b307a14c143562ff5e2e804e2 /ext/datasources/helium | |
parent | c8adfc4464ab430b06c07d2a70c9823c4bd45dc2 (diff) | |
download | mongo-6647871eecf5ba5df389b96e4f9fbc9cc1ccfdd0.tar.gz |
Update the configuration string parsing in Helium data source.
Diffstat (limited to 'ext/datasources/helium')
-rw-r--r-- | ext/datasources/helium/helium.c | 61 |
1 files changed, 36 insertions, 25 deletions
diff --git a/ext/datasources/helium/helium.c b/ext/datasources/helium/helium.c index 1239c88befa..ee08cbd97b3 100644 --- a/ext/datasources/helium/helium.c +++ b/ext/datasources/helium/helium.c @@ -2098,6 +2098,7 @@ helium_session_open_cursor(WT_DATA_SOURCE *wtds, WT_SESSION *session, CURSOR *cursor; DATA_SOURCE *ds; WT_CONFIG_ITEM v; + WT_CONFIG_PARSER *config_parser; WT_CURSOR *wtcursor; WT_EXTENSION_API *wtext; WT_SOURCE *ws; @@ -2106,6 +2107,7 @@ helium_session_open_cursor(WT_DATA_SOURCE *wtds, WT_SESSION *session, *new_cursor = NULL; + config_parser = NULL; cursor = NULL; ds = (DATA_SOURCE *)wtds; wtext = ds->wtext; @@ -2164,23 +2166,28 @@ helium_session_open_cursor(WT_DATA_SOURCE *wtds, WT_SESSION *session, if ((ret = master_uri_get(wtds, session, uri, &value)) != 0) goto err; - if ((ret = wtext->config_strget( - wtext, session, value, "key_format", &v)) != 0) + if ((ret = wiredtiger_config_parser_open( + session, value, strlen(value), &config_parser)) != 0) + EMSG_ERR(wtext, session, ret, + "Configuration string parser: %s", + wtext->strerror(ret)); + if ((ret = config_parser->get( + config_parser, "key_format", &v)) != 0) EMSG_ERR(wtext, session, ret, "key_format configuration: %s", wtext->strerror(ret)); ws->config_recno = v.len == 1 && v.str[0] == 'r'; - if ((ret = wtext->config_strget( - wtext, session, value, "value_format", &v)) != 0) + if ((ret = config_parser->get( + config_parser, "value_format", &v)) != 0) EMSG_ERR(wtext, session, ret, "value_format configuration: %s", wtext->strerror(ret)); ws->config_bitfield = v.len == 2 && isdigit(v.str[0]) && v.str[1] == 't'; - if ((ret = wtext->config_strget( - wtext, session, value, "helium_o_compress", &v)) != 0) + if ((ret = config_parser->get( + config_parser, "helium_o_compress", &v)) != 0) EMSG_ERR(wtext, session, ret, "helium_o_compress configuration: %s", wtext->strerror(ret)); @@ -2219,6 +2226,8 @@ err: if (ws != NULL && locked) ESET(unlock(wtext, session, &ws->lock)); cursor_destroy(cursor); } + if (config_parser != NULL) + config_parser->close(config_parser); free((void *)value); return (ret); } @@ -2882,19 +2891,19 @@ helium_config_read(WT_EXTENSION_API *wtext, WT_CONFIG_ITEM *config, char **devicep, HE_ENV *envp, int *env_setp, int *flagsp) { WT_CONFIG_ITEM k, v; - WT_CONFIG_SCAN *scan; + WT_CONFIG_PARSER *config_parser; int ret = 0, tret; *env_setp = 0; *flagsp = 0; - /* Set up the scan of the configuration arguments list. */ - if ((ret = wtext->config_scan_begin( - wtext, NULL, config->str, config->len, &scan)) != 0) + /* Traverse the configuration arguments list. */ + if ((ret = wiredtiger_config_parser_open( + NULL, config->str, config->len, &config_parser)) != 0) ERET(wtext, NULL, ret, - "WT_EXTENSION_API.config_scan_begin: %s", + "wiredtiger_config_parser_open: %s", wtext->strerror(ret)); - while ((ret = wtext->config_scan_next(wtext, scan, &k, &v)) == 0) { + while ((ret = config_parser->next(config_parser, &k, &v)) == 0) { if (string_match("helium_devices", k.str, k.len)) { if ((*devicep = calloc(1, v.len + 1)) == NULL) return (os_errno()); @@ -2924,13 +2933,11 @@ helium_config_read(WT_EXTENSION_API *wtext, WT_CONFIG_ITEM *config, ret = 0; if (ret != 0) EMSG_ERR(wtext, NULL, ret, - "WT_EXTENSION_API.config_scan_next: %s", - wtext->strerror(ret)); + "WT_CONFIG_PARSER.next: %s", wtext->strerror(ret)); -err: if ((tret = wtext->config_scan_end(wtext, scan)) != 0) +err: if ((tret = config_parser->close(config_parser)) != 0) EMSG(wtext, NULL, tret, - "WT_EXTENSION_API.config_scan_end: %s", - wtext->strerror(tret)); + "WT_CONFIG_PARSER.close: %s", wtext->strerror(tret)); return (ret); } @@ -3320,11 +3327,12 @@ wiredtiger_extension_init(WT_CONNECTION *connection, WT_CONFIG_ARG *config) DATA_SOURCE *ds; HELIUM_SOURCE *hs; WT_CONFIG_ITEM k, v; - WT_CONFIG_SCAN *scan; + WT_CONFIG_PARSER *config_parser; WT_EXTENSION_API *wtext; int vmajor, vminor, ret = 0; const char **p; + config_parser = NULL; ds = NULL; wtext = connection->get_extension_api(connection); @@ -3357,12 +3365,12 @@ wiredtiger_extension_init(WT_CONNECTION *connection, WT_CONFIG_ARG *config) wtext->strerror(ret)); /* Step through the list of Helium sources, opening each one. */ - if ((ret = - wtext->config_scan_begin(wtext, NULL, v.str, v.len, &scan)) != 0) + if ((ret = wiredtiger_config_parser_open( + NULL, v.str, v.len, &config_parser)) != 0) EMSG_ERR(wtext, NULL, ret, - "WT_EXTENSION_API.config_scan_begin: config: %s", + "wiredtiger_config_parser_open: config: %s", wtext->strerror(ret)); - while ((ret = wtext->config_scan_next(wtext, scan, &k, &v)) == 0) { + while ((ret = config_parser->next(config_parser, &k, &v)) == 0) { if (string_match("helium_verbose", k.str, k.len)) { verbose = v.val == 0 ? 0 : 1; continue; @@ -3372,12 +3380,13 @@ wiredtiger_extension_init(WT_CONNECTION *connection, WT_CONFIG_ARG *config) } if (ret != WT_NOTFOUND) EMSG_ERR(wtext, NULL, ret, - "WT_EXTENSION_API.config_scan_next: config: %s", + "WT_CONFIG_PARSER.next: config: %s", wtext->strerror(ret)); - if ((ret = wtext->config_scan_end(wtext, scan)) != 0) + if ((ret = config_parser->close(config_parser)) != 0) EMSG_ERR(wtext, NULL, ret, - "WT_EXTENSION_API.config_scan_end: config: %s", + "WT_CONFIG_PARSER.close: config: %s", wtext->strerror(ret)); + config_parser = NULL; /* Find and open the database transaction store. */ if ((ret = helium_source_open_txn(ds)) != 0) @@ -3414,6 +3423,8 @@ wiredtiger_extension_init(WT_CONNECTION *connection, WT_CONFIG_ARG *config) err: if (ds != NULL) ESET(helium_terminate((WT_DATA_SOURCE *)ds, NULL)); + if (config_parser != NULL) + (void)config_parser->close(config_parser); return (ret); } |