Skip to content
Árni Már Jónsson edited this page Jun 23, 2015 · 1 revision

= Preperation phase =

Each value created during the serialization phase gets a handle, which currently is a 32-bit unsigned integer. Handles may be re-used if the value has been seen before. We refer to this as normalization. This may be done for unicode values, bitvectors and certain inline values.

Handles are stored in a handle vector, which dues to its nature, may grow very large. This handle is fed into create functions for container values.

== Normalization ==

Normalization (described above) is implemented either by the value handle cache, or value -> handle mappings for unicode values and bitvectors.

== Value handle cache ==

Common value handles are cached, so that the handle vector doesn't grow too large. Boolean values, null values, empty slot values, and integers in a certain range are cached.

= Serialization phase =

Once the handle vector is ready, and the root has been set, the data structure is written either to a file, or a memory buffer.

Note that the state established during the preperation phase is changed during this phase, so there is no way to recover if we encounter an error.

All heap values are 4-byte aligned, relative to the heap.

The steps are, and in this order:

  • count how many vectors are empty
  • check for compression opportunities in vectors
  • populate the hash/key/value vectors for sets/maps, make sure keys are hashable, and that they are not duplicated
  • write out the offset vectors
  • write out the heap values Hide details Change log r1 by arnimarj on Dec 26, 2009 Diff initial check-in Go to: Older revisions All revisions of this file File info Size: 1479 bytes, 29 lines View raw file
Clone this wiki locally