From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTP id BAB6E24BAB for ; Mon, 12 Aug 2019 18:04:29 -0400 (EDT) Received: from turing.freelists.org ([127.0.0.1]) by localhost (turing.freelists.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 0qSmQgNa2B2G for ; Mon, 12 Aug 2019 18:04:29 -0400 (EDT) Received: from smtp21.mail.ru (smtp21.mail.ru [94.100.179.250]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTPS id 73096230DE for ; Mon, 12 Aug 2019 18:04:29 -0400 (EDT) Date: Tue, 13 Aug 2019 01:04:27 +0300 From: Konstantin Osipov Subject: [tarantool-patches] Re: [PATCH v2 5/8] sql: introduce a signature_mask for functions Message-ID: <20190812220427.GS32337@atlas> References: <6f6689986b1dd79adc478c5da9f1d458da42d483.1565275469.git.kshcherbatov@tarantool.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <6f6689986b1dd79adc478c5da9f1d458da42d483.1565275469.git.kshcherbatov@tarantool.org> Sender: tarantool-patches-bounce@freelists.org Errors-to: tarantool-patches-bounce@freelists.org Reply-To: tarantool-patches@freelists.org List-Help: List-Unsubscribe: List-software: Ecartis version 1.0.0 List-Id: tarantool-patches List-Subscribe: List-Owner: List-post: List-Archive: To: tarantool-patches@freelists.org Cc: korablev@tarantool.org, Kirill Shcherbatov * Kirill Shcherbatov [19/08/08 17:53]: > This patch replaces nArgs field with signature_mask bitmask that > allows to use an only hash table entry for all builtin functions > overloads. > > The code refactoring is not a goal of this patch: the most of > affected code would be removed in following patches. The role of > this patch itself is to introduce such mechanism (signature_mask) > in Tarantool's SQL. > > Needed for #2200, #4113, #2233 > --- > src/box/sql/sqlInt.h | 70 ++++++++++++++++++++------------ > src/box/sql/callback.c | 22 +++------- > src/box/sql/func.c | 91 ++++++++++++++++++------------------------ > src/box/sql/main.c | 4 +- > src/box/sql/vdbeaux.c | 6 ++- > 5 files changed, 94 insertions(+), 99 deletions(-) > > diff --git a/src/box/sql/sqlInt.h b/src/box/sql/sqlInt.h > index 941c87420..114ac0e4b 100644 > --- a/src/box/sql/sqlInt.h > +++ b/src/box/sql/sqlInt.h > @@ -1254,7 +1254,20 @@ struct type_def { > * field is used by per-connection app-def functions. > */ > struct FuncDef { > - i8 nArg; /* Number of arguments. -1 means unlimited */ > + /** > + * A bitmask representing all supported function > + * overloads. The function supports argc == n iff this > + * bitmask has bit n set 1. In particular case, a bitmask > + * (~0) means this function works with any possible > + * argument. > + * > + * The count of arguments for function is limited with > + * (CHAR_BITS*sizeof(uint64_t) - 1). When the highest bit > + * of the mask is set, this means that greater values > + * are supported. E.g. greatest function works correctly > + * with any number of input arguments. > + */ > + uint64_t signature_mask; Good idea, but why make the mask sooo big?-))) I don't think we have more than 3 arguments in any overloaded function? > + if (!column_mask_fieldno_is_set(p->signature_mask, (uint32_t)nArg)) > return 0; Are you sure you want to use column mask api just to test a bit? -- Konstantin Osipov, Moscow, Russia