Work in progress
TODO: TypedValue vs PropertyValue vs PropertyStore
Properties (specifically PropertyValues) get copied very often - we can compress them to optimize memory usage and performance.
The values themselves are stored encoded in a flat buffer. On an insertion the underlying storage buffer is resized if necessary and on removal the underlying storage buffer is shrinked if the new data can fit into a buffer that is 1/3 smaller than the current buffer. If it can't fit into a smaller buffer, the current buffer is used. All mappings are encoded independently of each other. TODO: elaborate more
Each mapping starts with an encoded metadata field that is used for several purposes:
The metadata field is always a single byte and its bits are used as follows:
int64_t
and uint32_t
) they are compressed so that they are stored into 1, 2, 4 or 8 bytes depending on their valueThe size of the metadata field is very important because it is encoded with each and every ID to value mapping. That is why every possible bit is used to store some useful information. Increasing the size of the metadata field will increase memory usage for every stored ID to value mapping. Bits 0-5 are always used in the same way but bits 6-7 can be used for various memory optimizations.
This section displays how each data type is stored, first row indicates header
int8_t
, int16_t
, int32_t
or int64_t