From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Date: Thu, 14 Feb 2019 17:09:25 +0300 From: Konstantin Osipov Subject: Re: [tarantool-patches] [PATCH v2 4/4] box: introduce tuple compare hint for string index Message-ID: <20190214140925.GD17583@chai> References: <48f09c5c8f53bfa63a52da90ffe4672ade7ad9ae.1550050245.git.kshcherbatov@tarantool.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <48f09c5c8f53bfa63a52da90ffe4672ade7ad9ae.1550050245.git.kshcherbatov@tarantool.org> To: tarantool-patches@freelists.org Cc: vdavydov.dev@gmail.com, Alexandr Lyapunov List-ID: * Kirill Shcherbatov [19/02/13 13:03]: > From: Alexandr Lyapunov > 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