From: Vladimir Davydov <vdavydov.dev@gmail.com> To: Konstantin Osipov <kostja@tarantool.org> Cc: tarantool-patches@freelists.org Subject: Re: [tarantool-patches] Re: [PATCH 03/12] key_def: cleanup virtual function initialization Date: Thu, 21 Feb 2019 15:05:13 +0300 [thread overview] Message-ID: <20190221120513.fk7qnlbtprlmhndw@esperanza> (raw) In-Reply-To: <20190221110128.GC3872@chai> On Thu, Feb 21, 2019 at 02:01:28PM +0300, Konstantin Osipov wrote: > * Vladimir Davydov <vdavydov.dev@gmail.com> [19/02/21 13:31]: > > Please use subject-verb-object, on other words, key_def_set_func, > key_def_set_extract_key_func, and so on. Done on the branch. The new patch is below. From aeb32f330b42ec42a1d993d0ac586206e923eab0 Mon Sep 17 00:00:00 2001 From: Vladimir Davydov <vdavydov.dev@gmail.com> Date: Tue, 19 Feb 2019 14:09:12 +0300 Subject: [PATCH] key_def: cleanup virtual function initialization - Rename key_def_set_cmp to key_def_set_func, because it sets not only comparators these days. - Rename tuple_hash_func_set and tuple_extract_key_set to key_def_set_hash_func and key_def_set_extract_func, because it's more like subject-verb-object naming convention used throughout the code. - Introduce key_def_set_compare_func and use it instead of setting comparators explicitly in key_def.c. diff --git a/src/box/key_def.c b/src/box/key_def.c index 9411ade3..5a75acb3 100644 --- a/src/box/key_def.c +++ b/src/box/key_def.c @@ -129,12 +129,11 @@ key_def_delete(struct key_def *def) } static void -key_def_set_cmp(struct key_def *def) +key_def_set_func(struct key_def *def) { - def->tuple_compare = tuple_compare_create(def); - def->tuple_compare_with_key = tuple_compare_with_key_create(def); - tuple_hash_func_set(def); - tuple_extract_key_set(def); + key_def_set_compare_func(def); + key_def_set_hash_func(def); + key_def_set_extract_func(def); } static void @@ -208,7 +207,7 @@ key_def_new(const struct key_part_def *parts, uint32_t part_count) &path_pool, TUPLE_OFFSET_SLOT_NIL, 0); } assert(path_pool == (char *)def + sz); - key_def_set_cmp(def); + key_def_set_func(def); return def; } @@ -261,7 +260,7 @@ box_key_def_new(uint32_t *fields, uint32_t *types, uint32_t part_count) NULL, COLL_NONE, SORT_ORDER_ASC, NULL, 0, NULL, TUPLE_OFFSET_SLOT_NIL, 0); } - key_def_set_cmp(key_def); + key_def_set_func(key_def); return key_def; } @@ -333,7 +332,7 @@ key_def_update_optionality(struct key_def *def, uint32_t min_field_count) if (def->has_optional_parts) break; } - key_def_set_cmp(def); + key_def_set_func(def); } int @@ -686,7 +685,7 @@ key_def_merge(const struct key_def *first, const struct key_def *second) part->offset_slot_cache, part->format_epoch); } assert(path_pool == (char *)new_def + sz); - key_def_set_cmp(new_def); + key_def_set_func(new_def); return new_def; } diff --git a/src/box/tuple_compare.cc b/src/box/tuple_compare.cc index ded802c7..cbdd150b 100644 --- a/src/box/tuple_compare.cc +++ b/src/box/tuple_compare.cc @@ -1049,7 +1049,7 @@ static const tuple_compare_t compare_slowpath_funcs[] = { tuple_compare_slowpath<true, true, true> }; -tuple_compare_t +static tuple_compare_t tuple_compare_create(const struct key_def *def) { int cmp_func_idx = (def->is_nullable ? 1 : 0) + @@ -1277,7 +1277,7 @@ static const tuple_compare_with_key_t compare_with_key_slowpath_funcs[] = { tuple_compare_with_key_slowpath<true, true, true> }; -tuple_compare_with_key_t +static tuple_compare_with_key_t tuple_compare_with_key_create(const struct key_def *def) { int cmp_func_idx = (def->is_nullable ? 1 : 0) + @@ -1322,3 +1322,10 @@ tuple_compare_with_key_create(const struct key_def *def) } /* }}} tuple_compare_with_key */ + +void +key_def_set_compare_func(struct key_def *def) +{ + def->tuple_compare = tuple_compare_create(def); + def->tuple_compare_with_key = tuple_compare_with_key_create(def); +} diff --git a/src/box/tuple_compare.h b/src/box/tuple_compare.h index e3a63204..f8fa6eb9 100644 --- a/src/box/tuple_compare.h +++ b/src/box/tuple_compare.h @@ -30,17 +30,15 @@ * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ -#include <stddef.h> #include <stdint.h> -#include <stdbool.h> - -#include "key_def.h" -#include "tuple.h" #if defined(__cplusplus) extern "C" { #endif /* defined(__cplusplus) */ +struct tuple; +struct key_def; + /** * Return the length of the longest common prefix of two tuples. * @param tuple_a first tuple @@ -53,19 +51,11 @@ tuple_common_key_parts(const struct tuple *tuple_a, const struct tuple *tuple_b, struct key_def *key_def); /** - * Create a comparison function for the key_def - * - * @param key_def key_definition - * @returns a comparision function + * Initialize comparator functions for the key_def. + * @param key_def key definition */ -tuple_compare_t -tuple_compare_create(const struct key_def *key_def); - -/** - * @copydoc tuple_compare_create() - */ -tuple_compare_with_key_t -tuple_compare_with_key_create(const struct key_def *key_def); +void +key_def_set_compare_func(struct key_def *def); #if defined(__cplusplus) } /* extern "C" */ diff --git a/src/box/tuple_extract_key.cc b/src/box/tuple_extract_key.cc index 5cf46724..17f06db7 100644 --- a/src/box/tuple_extract_key.cc +++ b/src/box/tuple_extract_key.cc @@ -356,7 +356,7 @@ static const tuple_extract_key_t extract_key_slowpath_funcs[] = { * Initialize tuple_extract_key() and tuple_extract_key_raw() */ void -tuple_extract_key_set(struct key_def *key_def) +key_def_set_extract_func(struct key_def *key_def) { if (key_def_is_sequential(key_def)) { if (key_def->has_optional_parts) { diff --git a/src/box/tuple_extract_key.h b/src/box/tuple_extract_key.h index 8a346595..7be16241 100644 --- a/src/box/tuple_extract_key.h +++ b/src/box/tuple_extract_key.h @@ -41,7 +41,7 @@ struct key_def; * @param key_def key definition */ void -tuple_extract_key_set(struct key_def *key_def); +key_def_set_extract_func(struct key_def *key_def); #if defined(__cplusplus) } /* extern "C" */ diff --git a/src/box/tuple_hash.cc b/src/box/tuple_hash.cc index 5bfd40cf..5213ae97 100644 --- a/src/box/tuple_hash.cc +++ b/src/box/tuple_hash.cc @@ -222,7 +222,7 @@ uint32_t key_hash_slowpath(const char *key, struct key_def *key_def); void -tuple_hash_func_set(struct key_def *key_def) { +key_def_set_hash_func(struct key_def *key_def) { if (key_def->is_nullable || key_def->has_json_paths) goto slowpath; /* diff --git a/src/box/tuple_hash.h b/src/box/tuple_hash.h index abc961bf..d87e3234 100644 --- a/src/box/tuple_hash.h +++ b/src/box/tuple_hash.h @@ -42,7 +42,7 @@ extern "C" { * @param key_def key definition */ void -tuple_hash_func_set(struct key_def *def); +key_def_set_hash_func(struct key_def *def); /** * Compute hash of a tuple field.
next prev parent reply other threads:[~2019-02-21 12:05 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 [this message] 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 ` [PATCH 10/12] vinyl: rename key stmt construction routine Vladimir Davydov 2019-02-21 11:15 ` [tarantool-patches] " 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=20190221120513.fk7qnlbtprlmhndw@esperanza \ --to=vdavydov.dev@gmail.com \ --cc=kostja@tarantool.org \ --cc=tarantool-patches@freelists.org \ --subject='Re: [tarantool-patches] Re: [PATCH 03/12] key_def: cleanup virtual function initialization' \ /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