diff options
author | Ramon Fernandez <rfmnyc@gmail.com> | 2015-11-19 09:37:38 -0500 |
---|---|---|
committer | Ramon Fernandez <rfmnyc@gmail.com> | 2015-11-19 09:41:39 -0500 |
commit | a0771ea5ec1b44537d3c409e3d712db24fd8e6bb (patch) | |
tree | 62517780ad0982ec80b8a6d968a72cf0474df617 /src/third_party/wiredtiger/ext | |
parent | 042d8fa2d252142489c5fa3009927bad20d77efb (diff) | |
download | mongo-a0771ea5ec1b44537d3c409e3d712db24fd8e6bb.tar.gz |
Import wiredtiger-wiredtiger-mongodb-3.2.0-rc3-177-g9d375e3.tar.gz from wiredtiger branch mongodb-3.2
ref: d9ec1ff..9d375e3
16c0a1a WT-1315 Fix some leaks with join cursors.
59857f9 WT-2222 Add statistics for named snapshots.
4368d39 WT-1315 Cursor join implementation
a72ddb7 WT-2218 Add truncate stats
fb9cebe WT-2224 Track which deleted refs are discarded by a split.
e2f1130 WT-2220 Split WT_TIMEDIFF macro into unit specific macros.
be412b5 WT-2182 when internal pages grow large enough, split them into their parents
ce8c091 WT-2219 Enhancements to in-memory testing
347d922 WT-2220 time_t cleanup.
08c0fcd WT-2217 change WT_CURSOR.insert to clear "set" key/value on return
d1b5e7f WT-2135 Fix log_only setting for backup cursor. Fix initialization.
78bd4ac WT-2210 raw compression fails if row-store recovery precedes column-store recovery
c1b2634 WT-2182 fixes for splitting up the tree.
0a1ee34 WT-2199 Fix transaction sync inconsistency.
ee31bb2 WT-2182 Simplify the split deepen logic.
c360d53 WT-2212 Add a "use_environment" config to "wiredtiger_open"
3f132a4 WT-2182 detect internal page split races.
Diffstat (limited to 'src/third_party/wiredtiger/ext')
-rw-r--r-- | src/third_party/wiredtiger/ext/extractors/csv/csv_extractor.c | 45 |
1 files changed, 34 insertions, 11 deletions
diff --git a/src/third_party/wiredtiger/ext/extractors/csv/csv_extractor.c b/src/third_party/wiredtiger/ext/extractors/csv/csv_extractor.c index 34b8d7c7c64..8d50cc7ec5d 100644 --- a/src/third_party/wiredtiger/ext/extractors/csv/csv_extractor.c +++ b/src/third_party/wiredtiger/ext/extractors/csv/csv_extractor.c @@ -49,7 +49,8 @@ typedef struct { WT_EXTRACTOR extractor; /* Must come first */ WT_EXTENSION_API *wt_api; /* Extension API */ - int field_num; /* Field to extract */ + int field; /* Field to extract */ + int format_isnum; /* Field contents are numeric */ } CSV_EXTRACTOR; /* @@ -61,15 +62,15 @@ csv_extract(WT_EXTRACTOR *extractor, WT_SESSION *session, const WT_ITEM *key, const WT_ITEM *value, WT_CURSOR *result_cursor) { char *copy, *p, *pend, *valstr; - const CSV_EXTRACTOR *cvs_extractor; - int i, ret; + const CSV_EXTRACTOR *csv_extractor; + int i, ret, val; size_t len; WT_EXTENSION_API *wtapi; (void)key; /* Unused parameters */ - cvs_extractor = (const CSV_EXTRACTOR *)extractor; - wtapi = cvs_extractor->wt_api; + csv_extractor = (const CSV_EXTRACTOR *)extractor; + wtapi = csv_extractor->wt_api; /* Unpack the value. */ if ((ret = wtapi->struct_unpack(wtapi, @@ -78,11 +79,11 @@ csv_extract(WT_EXTRACTOR *extractor, WT_SESSION *session, p = valstr; pend = strchr(p, ','); - for (i = 0; i < cvs_extractor->field_num && pend != NULL; i++) { + for (i = 0; i < csv_extractor->field && pend != NULL; i++) { p = pend + 1; pend = strchr(p, ','); } - if (i == cvs_extractor->field_num) { + if (i == csv_extractor->field) { if (pend == NULL) pend = p + strlen(p); /* @@ -95,7 +96,12 @@ csv_extract(WT_EXTRACTOR *extractor, WT_SESSION *session, return (errno); strncpy(copy, p, len); copy[len] = '\0'; - result_cursor->set_key(result_cursor, copy); + if (csv_extractor->format_isnum) { + if ((val = atoi(copy)) < 0) + return (EINVAL); + result_cursor->set_key(result_cursor, val); + } else + result_cursor->set_key(result_cursor, copy); ret = result_cursor->insert(result_cursor); free(copy); if (ret != 0) @@ -107,7 +113,7 @@ csv_extract(WT_EXTRACTOR *extractor, WT_SESSION *session, /* * csv_customize -- * The customize function creates a customized extractor, - * needed to save the field number. + * needed to save the field number and format. */ static int csv_customize(WT_EXTRACTOR *extractor, WT_SESSION *session, @@ -115,20 +121,37 @@ csv_customize(WT_EXTRACTOR *extractor, WT_SESSION *session, { const CSV_EXTRACTOR *orig; CSV_EXTRACTOR *csv_extractor; + WT_CONFIG_ITEM field, format; + WT_CONFIG_PARSER *parser; + WT_EXTENSION_API *wtapi; + int ret; long field_num; (void)session; /* Unused parameters */ (void)uri; /* Unused parameters */ orig = (const CSV_EXTRACTOR *)extractor; - field_num = strtol(appcfg->str, NULL, 10); + wtapi = orig->wt_api; + if ((ret = wtapi->config_parser_open(wtapi, session, appcfg->str, + appcfg->len, &parser)) != 0) + return (ret); + if ((ret = parser->get(parser, "field", &field)) != 0 || + (ret = parser->get(parser, "format", &format)) != 0) { + if (ret == WT_NOTFOUND) + return (EINVAL); + return (ret); + } + field_num = strtol(field.str, NULL, 10); if (field_num < 0 || field_num > INT_MAX) return (EINVAL); + if (format.len != 1 || (format.str[0] != 'S' && format.str[0] != 'i')) + return (EINVAL); if ((csv_extractor = calloc(1, sizeof(CSV_EXTRACTOR))) == NULL) return (errno); *csv_extractor = *orig; - csv_extractor->field_num = (int)field_num; + csv_extractor->field = field_num; + csv_extractor->format_isnum = (format.str[0] == 'i'); *customp = (WT_EXTRACTOR *)csv_extractor; return (0); } |