[tarantool-patches] [PATCH v2 4/4] box: introduce tuple compare hint for string index

Konstantin Osipov kostja at tarantool.org
Thu Feb 14 17:09:25 MSK 2019


* Kirill Shcherbatov <kshcherbatov at tarantool.org> [19/02/13 13:03]:
> From: Alexandr Lyapunov <aleks at tarantool.org>
> diff --git a/src/box/key_def.c b/src/box/key_def.c
> index 9411ade39..ceca1ebee 100644
> --- a/src/box/key_def.c
> +++ b/src/box/key_def.c
> @@ -135,6 +135,7 @@ key_def_set_cmp(struct key_def *def)
>  	def->tuple_compare_with_key = tuple_compare_with_key_create(def);
>  	tuple_hash_func_set(def);
>  	tuple_extract_key_set(def);
> +	tuple_hint_set(def);

I think the name of the function is confusing. The name suggests
that it says a tuple hint, whereas it sets a function which
evaluates the hint. Please prepare a separate patch which renames
existing functions tuple_hash_func_set and tuple_extract_key_set
to
key_def_set_{tuple_extract_key_func|tuple_hash_func|tuple_hint_func}.

> +/** @copydoc tuple_hint() */
> +typedef uint64_t (*tuple_hint_t)(const struct tuple *tuple,
> +				 struct key_def *key_def);

The func typedef should end with _f not with _t.

> +
> +/** @copydoc key_hint() */
> +typedef uint64_t (*key_hint_t)(const char *key, struct key_def *key_def);

Same here.

> +static int
> +memtx_hinted_tree_data_cmp(struct memtx_hinted_tree_data *a,
> +			   struct memtx_hinted_tree_data *b,
> +			   struct key_def *key_def)
> +{
> +	if (a->hint != b->hint)
> +		return a->hint < b->hint ? -1 : 1;
> +	return tuple_compare(a->tuple, b->tuple, key_def);
> +}

Looks like we need null-aware hints as well, to preserve online null ->
not null alter semantics. 

-- 
Konstantin Osipov, Moscow, Russia, +7 903 626 22 32
http://tarantool.io - www.twitter.com/kostja_osipov



More information about the Tarantool-patches mailing list