[tarantool-patches] [PATCH 2/5] decimal: allow to encode/decode decimals as MsgPack

Konstantin Osipov kostja at tarantool.org
Thu Jul 25 02:08:03 MSK 2019


* Serge Petrenko <sergepetrenko at tarantool.org> [19/07/17 18:34]:
> This patch adds the methods necessary to encode and decode decimals to
> MsgPack. MsgPack EXT type (MP_EXT) together with a new extension type
> MP_DECIMAL is used as a record header.
> 
> The decimal MsgPack representation looks like this:
> +--------+-------------------+------------+===============+
> | MP_EXT | length (optional) | MP_DECIMAL | PackedDecimal |
> +--------+-------------------+------------+===============+
> The whole record may be encoded and decoded with
> mp_encode_decimal() and mp_decode_decimal(). This is equivalent to
> performing mp_encode_extl()/mp_decode_extl() on the first 3 fields and
> decimal_pack/unpack() on the PackedDecimal field.

Please extend tarantool/msgpuck with libdecimal-agnostic data type
(e.g. struct mp_decimal { char data[] };, and encoders/decoders
from this struct.

Then use libdecimal api to fill this struct and pass to libmsgpuck
for encoding.

I think this patch is not worth having on its own, the next
logical step after patching msgpack is make sure net.box can
marshal decimals, and then - tarantool-python driver can read
them, then update test-run with the new python driver, then add a
new protocol test.


-- 
Konstantin Osipov, Moscow, Russia



More information about the Tarantool-patches mailing list