...
Thus for integer values it is possible to keep only their significant bytes, omitting their high insignificant bytes. That is even if the original data type of a field is INTEGER and should occupy 4 bytes but the actual value is below 128 and above -129 then we can store it just as a single byte and reflect this in the offset table.
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:
Does the tuple contain a nullmap?
hasNullmap = t[0] & 0b100;
How many bytes are occupied by the nullmap?
nullmapBytes = hasNullmap ? (N + 7) / 8 : 0;
How many bytes are occupied by one offset table entry?
offsetEntryBytes = 1 << (t[0] & 0b11);
How many bytes are occupied by the offset table?
offsetTableBytes = N * offsetEntryBytes;
What is offset of the value area?
valueBaseOffset = 1 + nullmapBytes + offsetTableBytes;
What is the whole tuple size?
tupleSize = valueBaseOffset + valueAreaSize
1. IEP-54: Schema-first Approach
...