[Tarantool-patches] [PATCH v4 11/16] sql: refactor COUNT() function

Vladislav Shpilevoy v.shpilevoy at tarantool.org
Tue Oct 5 00:53:50 MSK 2021


Nicely done!

On 01.10.2021 14:48, imeevma at tarantool.org wrote:
> Part of #4145
> ---
>  src/box/sql/func.c | 64 +++++++++++++++++++---------------------------
>  1 file changed, 26 insertions(+), 38 deletions(-)
> 
> diff --git a/src/box/sql/func.c b/src/box/sql/func.c
> index 94ec811ef..384c68be8 100644
> --- a/src/box/sql/func.c
> +++ b/src/box/sql/func.c
> @@ -154,6 +154,29 @@ fin_avg(struct sql_context *ctx)
>  		ctx->is_aborted = true;
>  }
>  
> +/** Implementation of the COUNT() function. */
> +static void
> +step_count(struct sql_context *ctx, int argc, struct Mem **argv)
> +{
> +	assert(argc == 0 || argc == 1);
> +	if (mem_is_null(ctx->pMem))
> +		mem_set_uint(ctx->pMem, 0);

Would be nice to have a 'begin' step for the aggregation
functions. This would allow to eliminate these 'if is null'
ifs in some step functions in favor of having +1 virtual 'begin'
call in the beginning.

Do you think it would simplify/speed up things? If you agree,
could you please create a ticket for that? As 'good first issue'
even.

If don't agree, then ignore this comment.


More information about the Tarantool-patches mailing list