box: add MsgPack encoding/decoding for UUID
A special format for encoding UUIDs to MsgPack is introduced. It is supported by both lua and C encoders/decoders, and it is now possible to insert UUIDs into spaces, but only into unindexed fields without format for now. Prerequisite #4268 @TarantoolBot document Title: Internals: msgpack format for UUID UUID values share the MessagePack type with decimals: both use MP_EXT. A new subtype is introduced for UUIDs, MP_UUID = `0x02` UUID is encoded as follows: ``` +--------+---------+-----------+ | MP_EXT | MP_UUID | UuidValue | +--------+---------+-----------+ ``` Since UUID is 16 bytes in size, the header, MP_EXT, is always the same: `0xd8`. MP_UUID = `0x02` follows. The header is followed by the 16 bytes of the UuidValue. UuidValue consists of 11 fields, which are encoded as big endian unsigned integers in the following order: `time_low` (4 bytes), `time_mid` (2 bytes), `time_hi_and_version` (2 bytes), `clock_seq_hi_and_reserved` (1 byte), `clock_seq_low` (1 byte), `node[0], ..., node[5]` (1 byte each). The total size of such a representation is 18 bytes, whereas storing uuids as strings requires from 34 (when '-'s are ommitted) to 38 bytes per UUID, giving a 2x space usage improvement.
Showing
- extra/exports 3 additions, 0 deletionsextra/exports
- src/lib/core/mp_extension_types.h 2 additions, 0 deletionssrc/lib/core/mp_extension_types.h
- src/lib/mpstream/mpstream.c 11 additions, 0 deletionssrc/lib/mpstream/mpstream.c
- src/lib/mpstream/mpstream.h 5 additions, 0 deletionssrc/lib/mpstream/mpstream.h
- src/lib/uuid/CMakeLists.txt 1 addition, 1 deletionsrc/lib/uuid/CMakeLists.txt
- src/lib/uuid/mp_uuid.c 97 additions, 0 deletionssrc/lib/uuid/mp_uuid.c
- src/lib/uuid/mp_uuid.h 90 additions, 0 deletionssrc/lib/uuid/mp_uuid.h
- src/lua/msgpack.c 21 additions, 6 deletionssrc/lua/msgpack.c
- src/lua/msgpackffi.lua 14 additions, 0 deletionssrc/lua/msgpackffi.lua
- src/lua/utils.c 22 additions, 1 deletionsrc/lua/utils.c
- src/lua/utils.h 5 additions, 0 deletionssrc/lua/utils.h
- src/lua/uuid.lua 0 additions, 9 deletionssrc/lua/uuid.lua
- test/app-tap/lua/serializer_test.lua 8 additions, 0 deletionstest/app-tap/lua/serializer_test.lua
- test/app-tap/msgpackffi.test.lua 2 additions, 1 deletiontest/app-tap/msgpackffi.test.lua
- test/app/msgpack.result 21 additions, 0 deletionstest/app/msgpack.result
- test/app/msgpack.test.lua 13 additions, 0 deletionstest/app/msgpack.test.lua
- test/app/uuid.result 12 additions, 1 deletiontest/app/uuid.result
- test/app/uuid.test.lua 5 additions, 0 deletionstest/app/uuid.test.lua
- test/box/tuple.result 81 additions, 0 deletionstest/box/tuple.result
- test/box/tuple.test.lua 25 additions, 0 deletionstest/box/tuple.test.lua
Loading
Please register or sign in to comment