From: Vladimir Davydov <vdavydov.dev@gmail.com> To: tarantool-patches@freelists.org Subject: [PATCH 4/7] Make tuple_bloom support multikey indexes Date: Wed, 8 May 2019 20:22:36 +0300 [thread overview] Message-ID: <b7aced73ee9404c55309fec4974438e9856a6da4.1557334828.git.vdavydov.dev@gmail.com> (raw) In-Reply-To: <cover.1557334828.git.vdavydov.dev@gmail.com> In-Reply-To: <cover.1557334828.git.vdavydov.dev@gmail.com> Just like in case of tuple_extract_key, simply pass multikey_idx to tuple_bloom_builder_add and tuple_bloom_maybe_has. For now, we always pass -1, but the following patches will pass offset in multikey array if the key definition is multikey. --- src/box/key_def.h | 3 ++- src/box/tuple_bloom.c | 16 +++++++++++----- src/box/tuple_bloom.h | 9 ++++++--- src/box/tuple_hash.cc | 4 ++-- src/box/vy_stmt.c | 4 ++-- 5 files changed, 23 insertions(+), 13 deletions(-) diff --git a/src/box/key_def.h b/src/box/key_def.h index 8b94b3b6..f4a1a8fd 100644 --- a/src/box/key_def.h +++ b/src/box/key_def.h @@ -675,13 +675,14 @@ tuple_hash_field(uint32_t *ph1, uint32_t *pcarry, const char **field, * @param pcarry - pointer to carry * @param tuple - tuple to hash * @param part - key part + * @param multikey_idx - multikey index hint * @return size of processed data * * This function updates @ph1 and @pcarry. */ uint32_t tuple_hash_key_part(uint32_t *ph1, uint32_t *pcarry, struct tuple *tuple, - struct key_part *part); + struct key_part *part, int multikey_idx); /** * Calculates a common hash value for a tuple diff --git a/src/box/tuple_bloom.c b/src/box/tuple_bloom.c index 935df798..99f19a2e 100644 --- a/src/box/tuple_bloom.c +++ b/src/box/tuple_bloom.c @@ -105,9 +105,11 @@ tuple_hash_array_add(struct tuple_hash_array *hash_arr, uint32_t hash) int tuple_bloom_builder_add(struct tuple_bloom_builder *builder, - struct tuple *tuple, struct key_def *key_def) + struct tuple *tuple, struct key_def *key_def, + int multikey_idx) { assert(builder->part_count == key_def->part_count); + assert(!key_def_is_multikey(key_def) || multikey_idx >= 0); uint32_t h = HASH_SEED; uint32_t carry = 0; @@ -115,7 +117,8 @@ tuple_bloom_builder_add(struct tuple_bloom_builder *builder, for (uint32_t i = 0; i < key_def->part_count; i++) { total_size += tuple_hash_key_part(&h, &carry, tuple, - &key_def->parts[i]); + &key_def->parts[i], + multikey_idx); uint32_t hash = PMurHash32_Result(h, carry, total_size); if (tuple_hash_array_add(&builder->parts[i], hash) != 0) return -1; @@ -198,9 +201,11 @@ tuple_bloom_delete(struct tuple_bloom *bloom) } bool -tuple_bloom_maybe_has(const struct tuple_bloom *bloom, - struct tuple *tuple, struct key_def *key_def) +tuple_bloom_maybe_has(const struct tuple_bloom *bloom, struct tuple *tuple, + struct key_def *key_def, int multikey_idx) { + assert(!key_def_is_multikey(key_def) || multikey_idx >= 0); + if (bloom->is_legacy) { return bloom_maybe_has(&bloom->parts[0], tuple_hash(tuple, key_def)); @@ -214,7 +219,8 @@ tuple_bloom_maybe_has(const struct tuple_bloom *bloom, for (uint32_t i = 0; i < key_def->part_count; i++) { total_size += tuple_hash_key_part(&h, &carry, tuple, - &key_def->parts[i]); + &key_def->parts[i], + multikey_idx); uint32_t hash = PMurHash32_Result(h, carry, total_size); if (!bloom_maybe_has(&bloom->parts[i], hash)) return false; diff --git a/src/box/tuple_bloom.h b/src/box/tuple_bloom.h index 5a630a49..1b7e4ac4 100644 --- a/src/box/tuple_bloom.h +++ b/src/box/tuple_bloom.h @@ -129,11 +129,13 @@ tuple_bloom_builder_delete(struct tuple_bloom_builder *builder); * @param builder - bloom filter builder * @param tuple - tuple to add * @param key_def - key definition + * @param multikey_idx - multikey index hint * @return 0 on success, -1 on OOM */ int tuple_bloom_builder_add(struct tuple_bloom_builder *builder, - struct tuple *tuple, struct key_def *key_def); + struct tuple *tuple, struct key_def *key_def, + int multikey_idx); /** * Add a key hash to a tuple bloom filter builder. @@ -169,12 +171,13 @@ tuple_bloom_delete(struct tuple_bloom *bloom); * @param bloom - bloom filter * @param tuple - tuple to check * @param key_def - key definition + * @param multikey_idx - multikey index hint * @return true if the tuple may have been stored in the bloom, * false if the tuple is definitely not in the bloom */ bool -tuple_bloom_maybe_has(const struct tuple_bloom *bloom, - struct tuple *tuple, struct key_def *key_def); +tuple_bloom_maybe_has(const struct tuple_bloom *bloom, struct tuple *tuple, + struct key_def *key_def, int multikey_idx); /** * Check if a tuple matching a key was stored in a tuple bloom filter. diff --git a/src/box/tuple_hash.cc b/src/box/tuple_hash.cc index 63de2bae..f90e1671 100644 --- a/src/box/tuple_hash.cc +++ b/src/box/tuple_hash.cc @@ -348,9 +348,9 @@ tuple_hash_null(uint32_t *ph1, uint32_t *pcarry) uint32_t tuple_hash_key_part(uint32_t *ph1, uint32_t *pcarry, struct tuple *tuple, - struct key_part *part) + struct key_part *part, int multikey_idx) { - const char *field = tuple_field_by_part(tuple, part, -1); + const char *field = tuple_field_by_part(tuple, part, multikey_idx); if (field == NULL) return tuple_hash_null(ph1, pcarry); return tuple_hash_field(ph1, pcarry, &field, part->coll); diff --git a/src/box/vy_stmt.c b/src/box/vy_stmt.c index 847b6196..ddad26f5 100644 --- a/src/box/vy_stmt.c +++ b/src/box/vy_stmt.c @@ -534,7 +534,7 @@ vy_stmt_bloom_builder_add(struct tuple_bloom_builder *builder, return tuple_bloom_builder_add_key(builder, data, part_count, key_def); } else { - return tuple_bloom_builder_add(builder, stmt, key_def); + return tuple_bloom_builder_add(builder, stmt, key_def, -1); } } @@ -548,7 +548,7 @@ vy_stmt_bloom_maybe_has(const struct tuple_bloom *bloom, return tuple_bloom_maybe_has_key(bloom, data, part_count, key_def); } else { - return tuple_bloom_maybe_has(bloom, stmt, key_def); + return tuple_bloom_maybe_has(bloom, stmt, key_def, -1); } } -- 2.11.0
next prev parent reply other threads:[~2019-05-08 17:22 UTC|newest] Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top 2019-05-08 17:22 [PATCH 0/7] Support multikey indexes in Vinyl Vladimir Davydov 2019-05-08 17:22 ` [PATCH 1/7] Make tuple comparison hints mandatory Vladimir Davydov 2019-05-09 5:58 ` [tarantool-patches] " Konstantin Osipov 2019-05-08 17:22 ` [PATCH 2/7] Get rid of tuple_field_by_part_multikey Vladimir Davydov 2019-05-08 17:22 ` [PATCH 3/7] Make tuple_extract_key support multikey indexes Vladimir Davydov 2019-05-08 17:22 ` Vladimir Davydov [this message] 2019-05-08 17:22 ` [PATCH 5/7] vinyl: use field_map_builder for constructing stmt field map Vladimir Davydov 2019-05-08 17:22 ` [PATCH 6/7] vinyl: use multikey hints while writing runs Vladimir Davydov 2019-05-08 17:22 ` [PATCH 7/7] vinyl: implement multikey index support Vladimir Davydov 2019-05-13 16:34 ` [PATCH] Use MULTIKEY_NONE instead of -1 Vladimir Davydov 2019-05-13 19:26 ` [PATCH 0/7] Support multikey indexes in Vinyl 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=b7aced73ee9404c55309fec4974438e9856a6da4.1557334828.git.vdavydov.dev@gmail.com \ --to=vdavydov.dev@gmail.com \ --cc=tarantool-patches@freelists.org \ --subject='Re: [PATCH 4/7] Make tuple_bloom support multikey indexes' \ /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