From: Kirill Shcherbatov <kshcherbatov@tarantool.org> To: tarantool-patches@freelists.org, vdavydov.dev@gmail.com Cc: Kirill Shcherbatov <kshcherbatov@tarantool.org> Subject: [PATCH v6 1/3] box: refactor key_def_set_compare_func routine Date: Wed, 13 Mar 2019 15:15:37 +0300 [thread overview] Message-ID: <34cf8ed7af4b1da74a89a260562abe08526cd4e8.1552478226.git.kshcherbatov@tarantool.org> (raw) In-Reply-To: <cover.1552478226.git.kshcherbatov@tarantool.org> Refactored tuple_compare_create and tuple_compare_with_key_create routines to set corresponding key_def field by it's own instead of returning pointer to function. This is required as in further patches we should set two key_def pointers: for hinted and for non-hinted routine version. Needed for #3961 --- src/box/tuple_compare.cc | 62 ++++++++++++++++++++++++---------------- 1 file changed, 38 insertions(+), 24 deletions(-) diff --git a/src/box/tuple_compare.cc b/src/box/tuple_compare.cc index cf4519ccb..1bcff2ca3 100644 --- a/src/box/tuple_compare.cc +++ b/src/box/tuple_compare.cc @@ -1049,21 +1049,26 @@ static const tuple_compare_t compare_slowpath_funcs[] = { tuple_compare_slowpath<true, true, true> }; -static tuple_compare_t -tuple_compare_create(const struct key_def *def) +void +key_def_set_tuple_compare(struct key_def *def) { int cmp_func_idx = (def->is_nullable ? 1 : 0) + 2 * (def->has_optional_parts ? 1 : 0) + 4 * (def->has_json_paths ? 1 : 0); if (def->is_nullable) { if (key_def_is_sequential(def)) { - if (def->has_optional_parts) - return tuple_compare_sequential<true, true>; - else - return tuple_compare_sequential<true, false>; + if (def->has_optional_parts) { + def->tuple_compare = + tuple_compare_sequential<true, true>; + } else { + def->tuple_compare = + tuple_compare_sequential<true, false>; + } } else { - return compare_slowpath_funcs[cmp_func_idx]; + def->tuple_compare = + compare_slowpath_funcs[cmp_func_idx]; } + return; } assert(! def->has_optional_parts); if (!key_def_has_collation(def) && !def->has_json_paths) { @@ -1078,13 +1083,15 @@ tuple_compare_create(const struct key_def *def) cmp_arr[k].p[i * 2 + 1]) break; if (i == def->part_count && - cmp_arr[k].p[i * 2] == UINT32_MAX) - return cmp_arr[k].f; + cmp_arr[k].p[i * 2] == UINT32_MAX) { + def->tuple_compare = cmp_arr[k].f; + return; + } } } - return key_def_is_sequential(def) ? - tuple_compare_sequential<false, false> : - compare_slowpath_funcs[cmp_func_idx]; + def->tuple_compare = key_def_is_sequential(def) ? + tuple_compare_sequential<false, false> : + compare_slowpath_funcs[cmp_func_idx]; } /* }}} tuple_compare */ @@ -1277,8 +1284,8 @@ static const tuple_compare_with_key_t compare_with_key_slowpath_funcs[] = { tuple_compare_with_key_slowpath<true, true, true> }; -static tuple_compare_with_key_t -tuple_compare_with_key_create(const struct key_def *def) +void +key_def_set_tuple_compare_with_key(struct key_def *def) { int cmp_func_idx = (def->is_nullable ? 1 : 0) + 2 * (def->has_optional_parts ? 1 : 0) + @@ -1286,15 +1293,19 @@ tuple_compare_with_key_create(const struct key_def *def) if (def->is_nullable) { if (key_def_is_sequential(def)) { if (def->has_optional_parts) { - return tuple_compare_with_key_sequential<true, + def->tuple_compare_with_key = + tuple_compare_with_key_sequential<true, true>; } else { - return tuple_compare_with_key_sequential<true, + def->tuple_compare_with_key = + tuple_compare_with_key_sequential<true, false>; } } else { - return compare_with_key_slowpath_funcs[cmp_func_idx]; + def->tuple_compare_with_key = + compare_with_key_slowpath_funcs[cmp_func_idx]; } + return; } assert(! def->has_optional_parts); if (!key_def_has_collation(def) && !def->has_json_paths) { @@ -1312,13 +1323,16 @@ tuple_compare_with_key_create(const struct key_def *def) break; } } - if (i == def->part_count) - return cmp_wk_arr[k].f; + if (i == def->part_count) { + def->tuple_compare_with_key = cmp_wk_arr[k].f; + return; + } } } - return key_def_is_sequential(def) ? - tuple_compare_with_key_sequential<false, false> : - compare_with_key_slowpath_funcs[cmp_func_idx]; + def->tuple_compare_with_key = + key_def_is_sequential(def) ? + tuple_compare_with_key_sequential<false, false> : + compare_with_key_slowpath_funcs[cmp_func_idx]; } /* }}} tuple_compare_with_key */ @@ -1326,6 +1340,6 @@ tuple_compare_with_key_create(const struct key_def *def) 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); + key_def_set_tuple_compare(def); + key_def_set_tuple_compare_with_key(def); } -- 2.21.0
next prev parent reply other threads:[~2019-03-13 12:15 UTC|newest] Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top 2019-03-13 12:15 [PATCH v6 0/3] box: introduce hint option for memtx tree index Kirill Shcherbatov 2019-03-13 12:15 ` Kirill Shcherbatov [this message] 2019-03-14 7:04 ` [PATCH v6 1/3] box: refactor key_def_set_compare_func routine Vladimir Davydov 2019-03-15 10:20 ` [tarantool-patches] " Kirill Shcherbatov 2019-03-15 10:55 ` Kirill Shcherbatov 2019-03-19 19:38 ` Vladimir Davydov 2019-03-13 12:15 ` [PATCH v6 2/3] memtx: introduce tuple compare hint Kirill Shcherbatov 2019-03-14 8:19 ` Vladimir Davydov 2019-03-15 10:20 ` [tarantool-patches] " Kirill Shcherbatov 2019-03-20 18:08 ` Vladimir Davydov 2019-03-13 12:15 ` [PATCH v6 3/3] box: introduce multikey indexes Kirill Shcherbatov
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=34cf8ed7af4b1da74a89a260562abe08526cd4e8.1552478226.git.kshcherbatov@tarantool.org \ --to=kshcherbatov@tarantool.org \ --cc=tarantool-patches@freelists.org \ --cc=vdavydov.dev@gmail.com \ --subject='Re: [PATCH v6 1/3] box: refactor key_def_set_compare_func 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