...
The list of supported data types for tuple fields is the same as in IEP-54[1]. Fixed-size values are stored in the little-endian byte order. If a value is equal to NULL then it is absent in the value area. This means that in the offset table the corresponding entry is equal to the previous entry. At the same time the corresponding bit in the nullmap is set.
...
In SQL standard there are no unsigned integers. So their support may be omitted. But should it become needed for some reason then a compressed unsigned integer must be zero-extended on decompression.
...
A date field occupies 3 bytes.
23 | 22 | 21 | 20 | 19 | 18 | 17 | 16 | 15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
year - 15 bits as a signed two's-complement |
value, so the highest bit is a sign bit | month - 4 bits | month day - 5 bits | |||||||||||||||||||||
byte 2 | byte 1 | byte 0 |
...
A time field may occupy 4, 5, or 6 bytes depending on the factional part precision that may be up to a millisecond, microsecond, and nanosecond respectively.
31 | 30 | 29 | 28 | 27 | 26 | 25 | 24 | 23 | 22 | 21 | 20 | 19 | 18 | 17 | 16 | 15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
padding - 5 zero bits | hour - 5 bits | minute - 6 bits | second - 6 bits | milliseconds - 10 bits | |||||||||||||||||||||||||||
byte 3 | byte 2 | byte 1 | byte 0 |
39 | 38 | 37 | 36 | 35 | 34 | 33 | 32 | 31 | 30 | 29 | 28 | 27 | 26 | 25 | 24 | 23 | 22 | 21 | 20 | 19 | 18 | 17 | 16 | 15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
3 zero bits | hour - 5 bits | minute - 6 bits | second - 6 bits | microseconds - 20 bits | |||||||||||||||||||||||||||||||||||
byte 4 | byte 3 | byte 2 | byte 1 | byte 0 |
47 | 46 | 45 | 44 | 43 | 42 | 41 | 40 | 39 | 38 | 37 | 36 | 35 | 34 | 33 | 32 | 31 | 30 | 29 | 28 | 27 | 26 | 25 | 24 | 23 | 22 | 21 | 20 | 19 | 18 | 17 | 16 | 15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
zero |
hour - 5 bits | minute - 6 bits | second - 6 bits |
nanoseconds - |
30 bits | |||||||||||||||||||||||||||||||||||||||||||||||
byte 5 | byte 4 | byte 3 | byte 2 | byte 1 | byte 0 |
A DateTime field is represented as a Date followed by a Time. So it may occupy from 7 to 9 bytes depending on the factional part of the Time value.
A timestamp field may occupy either 8 or 12 bytes. It consists of a 64-bit seconds part optionally followed by a 32-bit nanoseconds part. The nanosecond part can be omitted meaning that it is equal to zero. The seconds part is a signed number representing the time since so called Epoch time – 1970-01-01T00:00:00Z
. The nanoseconds part represents a nanoseconds and varies between 0 and 999,999,999.
A bitmask field is represented as a byte sequence in little-endian order.
Number and Decimal have identical representation. The Number type has a scale parameter but it is stored in the schema rather than in each tuple. Fields of these types are represented as a byte sequence containing the two's-complement binary value. Unlike all the other types here the bytes go in big-endian order. That is the most significant byte is at the very start of the sequence and the least significant is at its end.
If the number of fields is N and t is an array that stores a binary tuple we can find the answers for the following:
...