Skip to content
Snippets Groups Projects
Commit ed861743 authored by Mergen Imeev's avatar Mergen Imeev Committed by Kirill Yukhin
Browse files

core: introduce MP_INTERVAL

Part of #6773

NO_CHANGELOG=It will be added in another commit.

@TarantoolBot document
Title: New MsgPack extension type MP_INTERVAL

MsgPack extension type MP_INTERVAL was created to serialize values of
struct interval.

Description of serialized value:

------------------------------------------------------------
|MP_EXT|Size of packed interval|MP_INTERVAL|packed interval|
------------------------------------------------------------

Packed interval - packed number of non-zero fields and packed non-null
fields. Each packed field consists of two packed integer values - the
field ID and its value. The number of non-null fields can be zero, in
which case `packed interval` will be just packed integer `0`.

List of IDs:
0 - `year`
1 - `month`
2 - `week`
3 - `day`
4 - `hour`
5 - `minute`
6 - `second`
7 - `nanosecond`
8 - `adjust`

Example of packed interval value:

|C7|09|06|03|00|01|01|CCC8|03|D0B3|

Where
C7 - MP_EXT;
09 - size of packed interval value, 9 bytes;
06 - MP_INTERVAL;
03 - number of non-zero fields;
00 - ID of field `year`;
01 - packed value `1`;
01 - ID of field `month`;
CCC8 - packed value `200`;
03 - ID of field `day`;
D0B3 - packed value `-77`.

From there we can see, that the packed interval is actually
`1 year, 200 months and -77 days`.
parent ec911fce
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment