Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

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.

Date

...

Representation

A date field occupies 3 bytes.

23222120191817161514131211109876543210
year - 15 bits as a signed two's-complement
number, that is 1 bit of them
value, so the highest bit is a sign bitmonth - 4  bitsmonth day - 5 bits
byte 2byte 1byte 0

Time

...

Representation

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.

313029282726252423222120191817161514131211109876543210
padding - 5 zero bitshour - 5 bitsminute - 6 bitssecond - 6 bitsmilliseconds - 10 bits
byte 3byte 2byte 1byte 0


3938373635343332313029282726252423222120191817161514131211109876543210
3 zero bitshour - 5 bitsminute - 6 bitssecond - 6 bitsmicroseconds - 20 bits
byte 4byte 3byte 2byte 1byte 0


47464544434241403938373635343332313029282726252423222120191817161514131211109876543210
3
zero
bits
hour - 5 bitsminute - 6 bitssecond - 6 bits
microseconds
nanoseconds -
20
30 bits
byte 5byte 4byte 3byte 2byte 1byte 0

DateTime Representation

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.

Timestamp Representation

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.

Bitmask Representation

A bitmask field is represented as a byte sequence in little-endian order.

Number and Decimal representation

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.

Corollary

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:

...