Tarantool development patches archive
 help / color / mirror / Atom feed
From: "n.pettik" <korablev@tarantool.org>
To: tarantool-patches@freelists.org
Cc: Kirill Shcherbatov <kshcherbatov@tarantool.org>
Subject: [tarantool-patches] Re: [PATCH v2 4/5] sql: encode tuples with mpstream on Vdbe run
Date: Sat, 29 Dec 2018 15:26:23 +0200	[thread overview]
Message-ID: <F7CB9952-CC4B-43B3-BEEC-240C5D8056DF@tarantool.org> (raw)
In-Reply-To: <d5cdf182b5a828dbe0a0a78d5560e1329c671038.1546079994.git.kshcherbatov@tarantool.org>



> On 29 Dec 2018, at 12:49, Kirill Shcherbatov <kshcherbatov@tarantool.org> wrote:
> 
> Introduced new sql_vdbe_mem_encode_tuple and
> mpstream_encode_vdbe_mem routines to perform Vdbe memory to
> msgpack encoding on region without previous size estimation call.
> Got rid off sqlite3VdbeMsgpackRecordLen and

Nit: got rid of.

> +/**
> + * Perform encoding field_count Vdbe memory fields on region as
> + * msgpack array.
> + * @param fields The first Vdbe memory field to encode.
> + * @param field_count Count of fields to encode.
> + * @param[out] tuple_size Size of encoded tuple.
> + * @param region Region to use.
> + * @retval NULL on error, diag message is set.
> + * @retval no NULL tuple pointer on success.

Nit: not NULL … or simply “Pointer to valid tuple."

> @@ -1714,3 +1716,71 @@ sqlite3ValueBytes(sqlite3_value * pVal)
> 		return 0;
> 	return valueBytes(pVal);
> }
> +
> +/**
> + * Perform encoding memory variable to stream.
> + * @param stream Initialized mpstream encoder object.
> + * @param var Vdbe memory variable to encode with stream.
> + */
> +static void
> +mpstream_encode_vdbe_mem(struct mpstream *stream, struct Mem *var)
> +{
> +	assert(memIsValid(var));
> +	if (var->flags & MEM_Null) {
> +		mpstream_encode_nil(stream);
> +	} else if (var->flags & MEM_Real) {
> +		mpstream_encode_double(stream, var->u.r);
> +	} else if (var->flags & MEM_Int) {
> +		if (var->u.i >= 0)
> +			mpstream_encode_uint(stream, var->u.i);
> +		else
> +			mpstream_encode_int(stream, var->u.i);
> +	} else if (var->flags & MEM_Str) {
> +		mpstream_encode_strn(stream, var->z, var->n);
> +	} else if (var->flags & MEM_Bool) {
> +		mpstream_encode_bool(stream, var->u.b);
> +	} else {
> +		/*
> +		 * Emit BIN header iff the BLOB doesn't store
> +		 * MsgPack content.
> +		 */
> +		if ((var->flags & MEM_Subtype) == 0 ||
> +		     var->subtype != SQL_SUBTYPE_MSGPACK) {
> +			uint32_t binl = var->n +
> +					((var->flags & MEM_Zero) ?
> +					var->u.nZero : 0);
> +			mpstream_encode_binl(stream, binl);
> +		}
> +		mpstream_memcpy(stream, var->z, var->n);
> +		if (var->flags & MEM_Zero)
> +			mpstream_memset(stream, 0, var->u.nZero);
> +	}

Lets replace these if-else's with one switch.

The rest is OK.

  reply	other threads:[~2018-12-29 13:26 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-29 10:48 [tarantool-patches] [PATCH v2 0/5] sql: do not use OP_Delete+OP_Insert for UPDATES Kirill Shcherbatov
2018-12-29 10:48 ` [tarantool-patches] [PATCH v2 1/5] sql: clean-up vdbe_emit_constraint_checks Kirill Shcherbatov
2018-12-29 10:48 ` [tarantool-patches] [PATCH v2 2/5] sql: fix sql_vdbe_mem_alloc_region result memory Kirill Shcherbatov
2018-12-29 10:49 ` [tarantool-patches] [PATCH v2 3/5] sql: fix fkey exception for self-referenced table Kirill Shcherbatov
2018-12-29 13:26   ` [tarantool-patches] " n.pettik
2018-12-29 10:49 ` [tarantool-patches] [PATCH v2 4/5] sql: encode tuples with mpstream on Vdbe run Kirill Shcherbatov
2018-12-29 13:26   ` n.pettik [this message]
2018-12-29 15:28     ` [tarantool-patches] " Kirill Shcherbatov
2019-01-09 12:29       ` n.pettik
2018-12-29 10:49 ` [tarantool-patches] [PATCH v2 5/5] sql: do not use OP_Delete+OP_Insert for UPDATES Kirill Shcherbatov
2018-12-29 13:35   ` [tarantool-patches] " n.pettik
2018-12-29 15:31     ` Kirill Shcherbatov
2019-01-10 12:30 ` [tarantool-patches] Re: [PATCH v2 0/5] " Kirill Yukhin

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=F7CB9952-CC4B-43B3-BEEC-240C5D8056DF@tarantool.org \
    --to=korablev@tarantool.org \
    --cc=kshcherbatov@tarantool.org \
    --cc=tarantool-patches@freelists.org \
    --subject='[tarantool-patches] Re: [PATCH v2 4/5] sql: encode tuples with mpstream on Vdbe run' \
    /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