diff options
author | Michael Cahill <michael.cahill@wiredtiger.com> | 2012-10-19 11:18:54 +1100 |
---|---|---|
committer | Michael Cahill <michael.cahill@wiredtiger.com> | 2012-10-19 11:18:54 +1100 |
commit | 4147de0a3ad37e4316e65002e7beefa6b7444e02 (patch) | |
tree | 363b4ab557fb08626df74ca738a269c168376e10 | |
parent | 8af4c4f22d4836506ed5c2a2592980584a176e9f (diff) | |
download | mongo-4147de0a3ad37e4316e65002e7beefa6b7444e02.tar.gz |
Support indices on LSM by using 1-byte (padding) values, until LSM supports empty values natively.
-rw-r--r-- | src/cursor/cur_table.c | 4 | ||||
-rw-r--r-- | src/include/schema.h | 2 | ||||
-rw-r--r-- | src/schema/schema_create.c | 11 | ||||
-rw-r--r-- | src/schema/schema_open.c | 1 |
4 files changed, 17 insertions, 1 deletions
diff --git a/src/cursor/cur_table.c b/src/cursor/cur_table.c index cf1f79488bc..c606a94295b 100644 --- a/src/cursor/cur_table.c +++ b/src/cursor/cur_table.c @@ -30,6 +30,10 @@ static int __curtable_update(WT_CURSOR *cursor); WT_ERR(__wt_schema_project_merge(session, \ ctable->cg_cursors, \ idx->key_plan, idx->key_format, &(*__cp)->key)); \ + if (idx->need_value) { \ + (*__cp)->value.data = ""; \ + (*__cp)->value.size = 1; \ + } \ F_SET(*__cp, WT_CURSTD_KEY_SET | WT_CURSTD_VALUE_SET); \ WT_ERR((*__cp)->f(*__cp)); \ } \ diff --git a/src/include/schema.h b/src/include/schema.h index a3c2c32de2b..1e22a99a40d 100644 --- a/src/include/schema.h +++ b/src/include/schema.h @@ -31,6 +31,8 @@ struct __wt_index { const char *key_format; /* Key format */ const char *key_plan; /* Key projection plan */ const char *value_plan; /* Value projection plan */ + + int need_value; /* Index must have a non-empty value. */ }; /* diff --git a/src/schema/schema_create.c b/src/schema/schema_create.c index 589cd8dd3e9..a514d32346a 100644 --- a/src/schema/schema_create.c +++ b/src/schema/schema_create.c @@ -309,7 +309,16 @@ __create_index(WT_SESSION_IMPL *session, } if (ret != 0 && ret != WT_NOTFOUND) goto err; - /* Index values are empty: all columns are packed into the index key. */ + + /* + * Index values are normally empty: all columns are packed into the + * index key. The exception is LSM, which (currently) reserves empty + * values as tombstones. Use a single padding byte in that case. + */ + if (WT_PREFIX_MATCH(source, "lsm:")) + WT_ERR(__wt_buf_fmt(session, &fmt, "value_format=x,")); + else + WT_ERR(__wt_buf_fmt(session, &fmt, "value_format=,")); WT_ERR(__wt_buf_fmt(session, &fmt, "value_format=,key_format=")); WT_ERR(__wt_struct_reformat(session, table, icols.str, icols.len, (const char *)extra_cols.data, 0, &fmt)); diff --git a/src/schema/schema_open.c b/src/schema/schema_open.c index 3d0565096c2..dded4191c94 100644 --- a/src/schema/schema_open.c +++ b/src/schema/schema_open.c @@ -130,6 +130,7 @@ __open_index(WT_SESSION_IMPL *session, WT_TABLE *table, WT_INDEX *idx) WT_ERR(__wt_buf_fmt( session, buf, "%.*s", (int)cval.len, cval.str)); idx->source = __wt_buf_steal(session, buf, NULL); + idx->need_value = WT_PREFIX_MATCH(idx->source, "lsm:"); WT_ERR(__wt_config_getones(session, idx->config, "key_format", &cval)); WT_ERR(__wt_buf_fmt( |