diff --git a/src/box/vinyl.c b/src/box/vinyl.c index 7bfc08848ec5fd43e99e0bbe8fc5a6f26fc69734..b0b32f9176a9867fd78cb73c7281e8bb80c1d2a8 100644 --- a/src/box/vinyl.c +++ b/src/box/vinyl.c @@ -1435,8 +1435,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_key_new(lsm->env->key_format, + key_raw, part_count); if (key == NULL) return -1; int rc = vy_get(lsm, tx, rv, key, result); @@ -3799,7 +3799,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_key_new(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 29cd6eab38ab58b064895dcbac48f91db0ad0820..15be6bc544c8c0b93b89caa9fbd149711f7abb92 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_key_new(key_format, NULL, 0); if (env->empty_key == NULL) return -1; env->path = path; diff --git a/src/box/vy_stmt.c b/src/box/vy_stmt.c index 91966d8c30315d960054d59226ba790b4a6c724b..49b95e85b1cfc958c3dcc3f3c318c27f451f8124 100644 --- a/src/box/vy_stmt.c +++ b/src/box/vy_stmt.c @@ -236,20 +236,8 @@ 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_key_new(struct tuple_format *format, const char *key, uint32_t part_count) { assert(part_count == 0 || key != NULL); /* Key don't have field map */ @@ -649,7 +637,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_key_new(format, key_raw, part_count); /* Cleanup memory allocated by tuple_extract_key(). */ region_truncate(region, region_svp); return key; @@ -668,7 +656,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_key_new(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 0332bbdb5b55b5aba8e354724f2f64c667087890..97baf0f51af72c11b4956f8af9aaa02443e797c1 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,7 @@ 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_key_new(struct tuple_format *format, const char *key, uint32_t part_count); /** * Copy the key in a new memory area. @@ -549,7 +548,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. * @@ -559,13 +558,8 @@ vy_stmt_upsert_ops(const struct tuple *tuple, uint32_t *mp_size) static inline struct tuple * vy_key_from_msgpack(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_key_new(format, key, part_count); } /** diff --git a/test/unit/vy_iterators_helper.c b/test/unit/vy_iterators_helper.c index 0b0fe4abfd01137d5bb42776a1f54583a3fd046f..173d58db160b772ba409b63df69dac2e3d39e7d7 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_key_from_msgpack(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 0226a62ab56bcb65dd0ffa372ff375f75744c14f..5d114ccc4f7c5aa0073576328e0960ca4b0304e5 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_key_new(format, NULL, 0); struct mempool history_node_pool; mempool_create(&history_node_pool, cord_slab_cache(),