From: Vladimir Davydov <vdavydov.dev@gmail.com> To: kostja@tarantool.org Cc: tarantool-patches@freelists.org Subject: [PATCH 04/12] key_def: move cmp and hash functions declarations to key_def.h Date: Thu, 21 Feb 2019 13:26:04 +0300 [thread overview] Message-ID: <b3b337bca06f71433fc6b6b81756b1eb83e27b47.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> Most of them are already there - for instance see see tuple_extract_key and tuple_compare. Let's move the rest there too for consistency. --- src/box/key_def.c | 1 + src/box/key_def.h | 64 +++++++++++++++++++++++++++++++++++++++++++++++++ src/box/memtx_hash.c | 1 - src/box/sql/analyze.c | 1 - src/box/tuple_bloom.c | 1 - src/box/tuple_compare.h | 14 ----------- src/box/tuple_hash.cc | 1 + src/box/tuple_hash.h | 58 ++------------------------------------------ src/box/vy_run.c | 1 - 9 files changed, 68 insertions(+), 74 deletions(-) diff --git a/src/box/key_def.c b/src/box/key_def.c index 75e3a0be..92b2586d 100644 --- a/src/box/key_def.c +++ b/src/box/key_def.c @@ -30,6 +30,7 @@ */ #include "json/json.h" #include "key_def.h" +#include "tuple_format.h" #include "tuple_compare.h" #include "tuple_extract_key.h" #include "tuple_hash.h" diff --git a/src/box/key_def.h b/src/box/key_def.h index bf3e63b6..788a200d 100644 --- a/src/box/key_def.h +++ b/src/box/key_def.h @@ -503,6 +503,17 @@ tuple_extract_key_raw(const char *data, const char *data_end, } /** + * Return the length of the longest common prefix of two tuples. + * @param tuple_a first tuple + * @param tuple_b second tuple + * @param key_def key defintion + * @return number of key parts the two tuples have in common + */ +uint32_t +tuple_common_key_parts(const struct tuple *tuple_a, const struct tuple *tuple_b, + struct key_def *key_def); + +/** * Compare keys using the key definition. * @param key_a key parts with MessagePack array header * @param part_count_a the number of parts in the key_a @@ -551,6 +562,59 @@ tuple_compare_with_key(const struct tuple *tuple, const char *key, return key_def->tuple_compare_with_key(tuple, key, part_count, key_def); } +/** + * Compute hash of a tuple field. + * @param ph1 - pointer to running hash + * @param pcarry - pointer to carry + * @param field - pointer to field data + * @param coll - collation to use for hashing strings or NULL + * @return size of processed data + * + * This function updates @ph1 and @pcarry and advances @field + * by the number of processed bytes. + */ +uint32_t +tuple_hash_field(uint32_t *ph1, uint32_t *pcarry, const char **field, + struct coll *coll); + +/** + * Compute hash of a key part. + * @param ph1 - pointer to running hash + * @param pcarry - pointer to carry + * @param tuple - tuple to hash + * @param part - key part + * @return size of processed data + * + * This function updates @ph1 and @pcarry. + */ +uint32_t +tuple_hash_key_part(uint32_t *ph1, uint32_t *pcarry, const struct tuple *tuple, + struct key_part *part); + +/** + * Calculates a common hash value for a tuple + * @param tuple - a tuple + * @param key_def - key_def for field description + * @return - hash value + */ +static inline uint32_t +tuple_hash(const struct tuple *tuple, struct key_def *key_def) +{ + return key_def->tuple_hash(tuple, key_def); +} + +/** + * Calculate a common hash value for a key + * @param key - full key (msgpack fields w/o array marker) + * @param key_def - key_def for field description + * @return - hash value + */ +static inline uint32_t +key_hash(const char *key, struct key_def *key_def) +{ + return key_def->key_hash(key, key_def); +} + #if defined(__cplusplus) } /* extern "C" */ #endif /* defined(__cplusplus) */ diff --git a/src/box/memtx_hash.c b/src/box/memtx_hash.c index eae07e8a..511d0e51 100644 --- a/src/box/memtx_hash.c +++ b/src/box/memtx_hash.c @@ -32,7 +32,6 @@ #include "say.h" #include "fiber.h" #include "tuple.h" -#include "tuple_hash.h" #include "memtx_engine.h" #include "space.h" #include "schema.h" /* space_cache_find() */ diff --git a/src/box/sql/analyze.c b/src/box/sql/analyze.c index e0f2724a..8c83288e 100644 --- a/src/box/sql/analyze.c +++ b/src/box/sql/analyze.c @@ -108,7 +108,6 @@ #include "box/box.h" #include "box/index.h" #include "box/key_def.h" -#include "box/tuple_compare.h" #include "box/schema.h" #include "third_party/qsort_arg.h" diff --git a/src/box/tuple_bloom.c b/src/box/tuple_bloom.c index 0ea552aa..cf887c7b 100644 --- a/src/box/tuple_bloom.c +++ b/src/box/tuple_bloom.c @@ -41,7 +41,6 @@ #include "errcode.h" #include "key_def.h" #include "tuple.h" -#include "tuple_hash.h" #include "salad/bloom.h" #include "trivia/util.h" #include "third_party/PMurHash.h" diff --git a/src/box/tuple_compare.h b/src/box/tuple_compare.h index baecbafe..2193335f 100644 --- a/src/box/tuple_compare.h +++ b/src/box/tuple_compare.h @@ -30,27 +30,13 @@ * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ -#include <stdint.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 - * @param tuple_b second tuple - * @param key_def key defintion - * @return number of key parts the two tuples have in common - */ -uint32_t -tuple_common_key_parts(const struct tuple *tuple_a, const struct tuple *tuple_b, - struct key_def *key_def); - -/** * Initialize comparator functions for the key_def. * @param key_def key definition */ diff --git a/src/box/tuple_hash.cc b/src/box/tuple_hash.cc index 5bfd40cf..82d145ab 100644 --- a/src/box/tuple_hash.cc +++ b/src/box/tuple_hash.cc @@ -30,6 +30,7 @@ */ #include "tuple_hash.h" +#include "tuple.h" #include "third_party/PMurHash.h" #include "coll.h" #include <math.h> diff --git a/src/box/tuple_hash.h b/src/box/tuple_hash.h index abc961bf..431613b5 100644 --- a/src/box/tuple_hash.h +++ b/src/box/tuple_hash.h @@ -30,13 +30,12 @@ * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ -#include "key_def.h" -#include "tuple.h" - #if defined(__cplusplus) extern "C" { #endif /* defined(__cplusplus) */ +struct key_def; + /** * Initialize tuple_hash() and key_hash() function for the key_def * @param key_def key definition @@ -44,59 +43,6 @@ extern "C" { void tuple_hash_func_set(struct key_def *def); -/** - * Compute hash of a tuple field. - * @param ph1 - pointer to running hash - * @param pcarry - pointer to carry - * @param field - pointer to field data - * @param coll - collation to use for hashing strings or NULL - * @return size of processed data - * - * This function updates @ph1 and @pcarry and advances @field - * by the number of processed bytes. - */ -uint32_t -tuple_hash_field(uint32_t *ph1, uint32_t *pcarry, const char **field, - struct coll *coll); - -/** - * Compute hash of a key part. - * @param ph1 - pointer to running hash - * @param pcarry - pointer to carry - * @param tuple - tuple to hash - * @param part - key part - * @return size of processed data - * - * This function updates @ph1 and @pcarry. - */ -uint32_t -tuple_hash_key_part(uint32_t *ph1, uint32_t *pcarry, const struct tuple *tuple, - struct key_part *part); - -/** - * Calculates a common hash value for a tuple - * @param tuple - a tuple - * @param key_def - key_def for field description - * @return - hash value - */ -static inline uint32_t -tuple_hash(const struct tuple *tuple, struct key_def *key_def) -{ - return key_def->tuple_hash(tuple, key_def); -} - -/** - * Calculate a common hash value for a key - * @param key - full key (msgpack fields w/o array marker) - * @param key_def - key_def for field description - * @return - hash value - */ -static inline uint32_t -key_hash(const char *key, struct key_def *key_def) -{ - return key_def->key_hash(key, key_def); -} - #if defined(__cplusplus) } /* extern "C" */ #endif /* defined(__cplusplus) */ diff --git a/src/box/vy_run.c b/src/box/vy_run.c index 7b15603e..14975bdf 100644 --- a/src/box/vy_run.c +++ b/src/box/vy_run.c @@ -41,7 +41,6 @@ #include "replication.h" #include "tuple_bloom.h" -#include "tuple_compare.h" #include "xlog.h" #include "xrow.h" #include "vy_history.h" -- 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 ` Vladimir Davydov [this message] 2019-02-21 11:02 ` [tarantool-patches] Re: [PATCH 04/12] key_def: move cmp and hash functions declarations to key_def.h 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=b3b337bca06f71433fc6b6b81756b1eb83e27b47.1550744027.git.vdavydov.dev@gmail.com \ --to=vdavydov.dev@gmail.com \ --cc=kostja@tarantool.org \ --cc=tarantool-patches@freelists.org \ --subject='Re: [PATCH 04/12] key_def: move cmp and hash functions declarations to key_def.h' \ /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