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 6D36122153 for ; Sat, 29 Dec 2018 08:26:25 -0500 (EST) 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 X5H-0nkwRSBN for ; Sat, 29 Dec 2018 08:26:25 -0500 (EST) Received: from smtp57.i.mail.ru (smtp57.i.mail.ru [217.69.128.37]) (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 2A53A201C7 for ; Sat, 29 Dec 2018 08:26:25 -0500 (EST) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 12.0 \(3445.100.39\)) Subject: [tarantool-patches] Re: [PATCH v2 4/5] sql: encode tuples with mpstream on Vdbe run From: "n.pettik" In-Reply-To: Date: Sat, 29 Dec 2018 15:26:23 +0200 Content-Transfer-Encoding: quoted-printable Message-Id: References: 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: Kirill Shcherbatov > On 29 Dec 2018, at 12:49, Kirill Shcherbatov = wrote: >=20 > 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 =E2=80=A6 or simply =E2=80=9CPointer 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 >=3D 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) =3D=3D 0 || > + var->subtype !=3D SQL_SUBTYPE_MSGPACK) { > + uint32_t binl =3D 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.