From: Vladimir Davydov <vdavydov.dev@gmail.com> To: kostja@tarantool.org Cc: tarantool-patches@freelists.org Subject: [PATCH 10/12] vinyl: rename key stmt construction routine Date: Thu, 21 Feb 2019 13:26:10 +0300 [thread overview] Message-ID: <fb28011a2546828fdb54b7eaa184037c62238da3.1550744027.git.vdavydov.dev@gmail.com> (raw) In-Reply-To: <cover.1550744027.git.vdavydov.dev@gmail.com> In-Reply-To: <cover.1550744027.git.vdavydov.dev@gmail.com> Currently, it's called vy_stmt_new_select, but soon a key statement will be allowed to have any type, not just IPROTO_SELECT. So let's rename it to vy_stmt_new_key. Let's also rename the wrapper vy_key_from_msgpack to vy_stmt_new_key_from_array, because its key feature is that in contrast to vy_stmt_new_key it takes a msgpack array instead of key data + part count. --- src/box/vinyl.c | 14 +++++++------- src/box/vy_lsm.c | 22 +++++++++++----------- src/box/vy_scheduler.c | 4 ++-- src/box/vy_stmt.c | 19 ++++--------------- src/box/vy_stmt.h | 19 +++++++------------ test/unit/vy_iterators_helper.c | 4 +--- test/unit/vy_mem.c | 2 +- 7 files changed, 33 insertions(+), 51 deletions(-) diff --git a/src/box/vinyl.c b/src/box/vinyl.c index c469077e..925784b0 100644 --- a/src/box/vinyl.c +++ b/src/box/vinyl.c @@ -1436,8 +1436,8 @@ vy_get_by_raw_key(struct vy_lsm *lsm, struct vy_tx *tx, const char *key_raw, uint32_t part_count, struct tuple **result) { - struct tuple *key = vy_stmt_new_select(lsm->env->key_format, - key_raw, part_count); + struct tuple *key = vy_stmt_new_key(lsm->env->key_format, + key_raw, part_count); if (key == NULL) return -1; int rc = vy_get(lsm, tx, rv, key, result); @@ -2914,14 +2914,14 @@ vy_prepare_send_slice(struct vy_join_ctx *ctx, goto out; if (slice_info->begin != NULL) { - begin = vy_key_from_msgpack(ctx->env->lsm_env.key_format, - slice_info->begin); + begin = vy_stmt_new_key_from_array(ctx->env->lsm_env.key_format, + slice_info->begin); if (begin == NULL) goto out; } if (slice_info->end != NULL) { - end = vy_key_from_msgpack(ctx->env->lsm_env.key_format, - slice_info->end); + end = vy_stmt_new_key_from_array(ctx->env->lsm_env.key_format, + slice_info->end); if (end == NULL) goto out; } @@ -3793,7 +3793,7 @@ vinyl_index_create_iterator(struct index *base, enum iterator_type type, "mempool", "struct vinyl_iterator"); return NULL; } - it->key = vy_stmt_new_select(lsm->env->key_format, key, part_count); + it->key = vy_stmt_new_key(lsm->env->key_format, key, part_count); if (it->key == NULL) { mempool_free(&env->iterator_pool, it); return NULL; diff --git a/src/box/vy_lsm.c b/src/box/vy_lsm.c index eca8a334..2bb56d87 100644 --- a/src/box/vy_lsm.c +++ b/src/box/vy_lsm.c @@ -74,7 +74,7 @@ vy_lsm_env_create(struct vy_lsm_env *env, const char *path, vy_upsert_thresh_cb upsert_thresh_cb, void *upsert_thresh_arg) { - env->empty_key = vy_stmt_new_select(key_format, NULL, 0); + env->empty_key = vy_stmt_new_key(key_format, NULL, 0); if (env->empty_key == NULL) return -1; env->path = path; @@ -387,14 +387,14 @@ vy_lsm_recover_slice(struct vy_lsm *lsm, struct vy_range *range, struct vy_run *run; if (slice_info->begin != NULL) { - begin = vy_key_from_msgpack(lsm->env->key_format, - slice_info->begin); + begin = vy_stmt_new_key_from_array(lsm->env->key_format, + slice_info->begin); if (begin == NULL) goto out; } if (slice_info->end != NULL) { - end = vy_key_from_msgpack(lsm->env->key_format, - slice_info->end); + end = vy_stmt_new_key_from_array(lsm->env->key_format, + slice_info->end); if (end == NULL) goto out; } @@ -433,14 +433,14 @@ vy_lsm_recover_range(struct vy_lsm *lsm, struct vy_range *range = NULL; if (range_info->begin != NULL) { - begin = vy_key_from_msgpack(lsm->env->key_format, - range_info->begin); + begin = vy_stmt_new_key_from_array(lsm->env->key_format, + range_info->begin); if (begin == NULL) goto out; } if (range_info->end != NULL) { - end = vy_key_from_msgpack(lsm->env->key_format, - range_info->end); + end = vy_stmt_new_key_from_array(lsm->env->key_format, + range_info->end); if (end == NULL) goto out; } @@ -1069,8 +1069,8 @@ vy_lsm_split_range(struct vy_lsm *lsm, struct vy_range *range) /* * Determine new ranges' boundaries. */ - struct tuple *split_key = vy_key_from_msgpack(key_format, - split_key_raw); + struct tuple *split_key = vy_stmt_new_key_from_array(key_format, + split_key_raw); if (split_key == NULL) goto fail; diff --git a/src/box/vy_scheduler.c b/src/box/vy_scheduler.c index f0e47fce..ad28712b 100644 --- a/src/box/vy_scheduler.c +++ b/src/box/vy_scheduler.c @@ -1150,10 +1150,10 @@ vy_task_dump_complete(struct vy_task *task) * intersecting the run or NULL if the run itersects all * ranges. */ - min_key = vy_key_from_msgpack(key_format, new_run->info.min_key); + min_key = vy_stmt_new_key_from_array(key_format, new_run->info.min_key); if (min_key == NULL) goto fail; - max_key = vy_key_from_msgpack(key_format, new_run->info.max_key); + max_key = vy_stmt_new_key_from_array(key_format, new_run->info.max_key); if (max_key == NULL) { tuple_unref(min_key); goto fail; diff --git a/src/box/vy_stmt.c b/src/box/vy_stmt.c index 57abad23..5ac7d833 100644 --- a/src/box/vy_stmt.c +++ b/src/box/vy_stmt.c @@ -236,20 +236,9 @@ vy_stmt_dup_lsregion(const struct tuple *stmt, struct lsregion *lsregion, return mem_stmt; } -/** - * Create the key statement from raw MessagePack data. - * @param format Format of an index. - * @param key MessagePack data that contain an array of - * fields WITHOUT the array header. - * @param part_count Count of the key fields that will be saved as - * result. - * - * @retval not NULL Success. - * @retval NULL Memory allocation error. - */ struct tuple * -vy_stmt_new_select(struct tuple_format *format, const char *key, - uint32_t part_count) +vy_stmt_new_key(struct tuple_format *format, const char *key, + uint32_t part_count) { assert(part_count == 0 || key != NULL); /* Key don't have field map */ @@ -629,7 +618,7 @@ vy_stmt_extract_key(const struct tuple *stmt, struct key_def *key_def, return NULL; uint32_t part_count = mp_decode_array(&key_raw); assert(part_count == key_def->part_count); - struct tuple *key = vy_stmt_new_select(format, key_raw, part_count); + struct tuple *key = vy_stmt_new_key(format, key_raw, part_count); /* Cleanup memory allocated by tuple_extract_key(). */ region_truncate(region, region_svp); return key; @@ -648,7 +637,7 @@ vy_stmt_extract_key_raw(const char *data, const char *data_end, return NULL; uint32_t part_count = mp_decode_array(&key_raw); assert(part_count == key_def->part_count); - struct tuple *key = vy_stmt_new_select(format, key_raw, part_count); + struct tuple *key = vy_stmt_new_key(format, key_raw, part_count); /* Cleanup memory allocated by tuple_extract_key_raw(). */ region_truncate(region, region_svp); return key; diff --git a/src/box/vy_stmt.h b/src/box/vy_stmt.h index 3881a2f4..6c834aee 100644 --- a/src/box/vy_stmt.h +++ b/src/box/vy_stmt.h @@ -382,7 +382,7 @@ vy_stmt_compare_with_raw_key(const struct tuple *stmt, const char *key, } /** - * Create the SELECT statement from raw MessagePack data. + * Create a key statement from raw MessagePack data. * @param format Format of an index. * @param key MessagePack data that contain an array of * fields WITHOUT the array header. @@ -393,8 +393,8 @@ vy_stmt_compare_with_raw_key(const struct tuple *stmt, const char *key, * @retval not NULL Success. */ struct tuple * -vy_stmt_new_select(struct tuple_format *format, const char *key, - uint32_t part_count); +vy_stmt_new_key(struct tuple_format *format, const char *key, + uint32_t part_count); /** * Create a new surrogate DELETE from @a key using format. @@ -541,7 +541,7 @@ vy_stmt_upsert_ops(const struct tuple *tuple, uint32_t *mp_size) } /** - * Create the SELECT statement from MessagePack array. + * Create a key statement from MessagePack array. * @param format Format of an index. * @param key MessagePack array of key fields. * @@ -549,15 +549,10 @@ vy_stmt_upsert_ops(const struct tuple *tuple, uint32_t *mp_size) * @retval NULL Memory error. */ static inline struct tuple * -vy_key_from_msgpack(struct tuple_format *format, const char *key) +vy_stmt_new_key_from_array(struct tuple_format *format, const char *key) { - uint32_t part_count; - /* - * The statement already is a key, so simply copy it in - * the new struct vy_stmt as SELECT. - */ - part_count = mp_decode_array(&key); - return vy_stmt_new_select(format, key, part_count); + uint32_t part_count = mp_decode_array(&key); + return vy_stmt_new_key(format, key, part_count); } /** diff --git a/test/unit/vy_iterators_helper.c b/test/unit/vy_iterators_helper.c index bcb60001..1e61ec97 100644 --- a/test/unit/vy_iterators_helper.c +++ b/test/unit/vy_iterators_helper.c @@ -117,9 +117,7 @@ vy_new_simple_stmt(struct tuple_format *format, break; } case IPROTO_SELECT: { - const char *key = buf; - uint part_count = mp_decode_array(&key); - ret = vy_stmt_new_select(stmt_env.key_format, key, part_count); + ret = vy_stmt_new_key_from_array(stmt_env.key_format, buf); fail_if(ret == NULL); break; } diff --git a/test/unit/vy_mem.c b/test/unit/vy_mem.c index 0226a62a..da4117c5 100644 --- a/test/unit/vy_mem.c +++ b/test/unit/vy_mem.c @@ -86,7 +86,7 @@ test_iterator_restore_after_insertion() struct slab_cache *slab_cache = cord_slab_cache(); lsregion_create(&lsregion, slab_cache->arena); - struct tuple *select_key = vy_stmt_new_select(format, "", 0); + struct tuple *select_key = vy_stmt_new_key(format, NULL, 0); struct mempool history_node_pool; mempool_create(&history_node_pool, cord_slab_cache(), -- 2.11.0
next prev parent reply other threads:[~2019-02-21 10:26 UTC|newest] Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top 2019-02-21 10:26 [PATCH 00/12] vinyl: do not fill secondary tuples with nulls Vladimir Davydov 2019-02-21 10:26 ` [PATCH 01/12] vinyl: use vy_lsm_env::empty_key where appropriate Vladimir Davydov 2019-02-21 10:59 ` [tarantool-patches] " Konstantin Osipov 2019-02-21 10:26 ` [PATCH 02/12] vinyl: make vy_tuple_delete static Vladimir Davydov 2019-02-21 11:00 ` [tarantool-patches] " Konstantin Osipov 2019-02-21 10:26 ` [PATCH 03/12] key_def: cleanup virtual function initialization Vladimir Davydov 2019-02-21 11:01 ` [tarantool-patches] " Konstantin Osipov 2019-02-21 12:05 ` Vladimir Davydov 2019-02-21 10:26 ` [PATCH 04/12] key_def: move cmp and hash functions declarations to key_def.h Vladimir Davydov 2019-02-21 11:02 ` [tarantool-patches] " Konstantin Osipov 2019-02-21 10:26 ` [PATCH 05/12] vinyl: move vy_tuple_key_contains_null to generic code Vladimir Davydov 2019-02-21 11:02 ` [tarantool-patches] " Konstantin Osipov 2019-02-21 10:26 ` [PATCH 06/12] vinyl: move vy_key_dup " Vladimir Davydov 2019-02-21 11:04 ` [tarantool-patches] " Konstantin Osipov 2019-02-21 11:52 ` Vladimir Davydov 2019-02-21 10:26 ` [PATCH 07/12] vinyl: sanitize full/empty key stmt detection Vladimir Davydov 2019-02-21 11:10 ` [tarantool-patches] " Konstantin Osipov 2019-02-21 12:11 ` Vladimir Davydov 2019-03-01 12:57 ` Vladimir Davydov 2019-02-21 10:26 ` [PATCH 08/12] vinyl: remove optimized comparators Vladimir Davydov 2019-02-21 11:11 ` [tarantool-patches] " Konstantin Osipov 2019-02-21 10:26 ` [PATCH 09/12] vinyl: introduce statement environment Vladimir Davydov 2019-02-21 11:14 ` [tarantool-patches] " Konstantin Osipov 2019-02-21 10:26 ` Vladimir Davydov [this message] 2019-02-21 11:15 ` [tarantool-patches] Re: [PATCH 10/12] vinyl: rename key stmt construction routine Konstantin Osipov 2019-02-21 12:14 ` Vladimir Davydov 2019-02-21 10:26 ` [PATCH 11/12] vinyl: don't use IPROTO_SELECT type for key statements Vladimir Davydov 2019-02-21 11:16 ` [tarantool-patches] " Konstantin Osipov 2019-02-21 10:26 ` [PATCH 12/12] vinyl: do not fill secondary tuples with nulls when decoded Vladimir Davydov 2019-02-21 15:39 ` [PATCH 00/12] vinyl: do not fill secondary tuples with nulls Vladimir Davydov
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=fb28011a2546828fdb54b7eaa184037c62238da3.1550744027.git.vdavydov.dev@gmail.com \ --to=vdavydov.dev@gmail.com \ --cc=kostja@tarantool.org \ --cc=tarantool-patches@freelists.org \ --subject='Re: [PATCH 10/12] vinyl: rename key stmt construction routine' \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox