Description
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.
Requested by @sergepetrenko in tarantool/tarantool@d68fc29.