Expand description
Flatbuffer serialization. Flatbuffer serialization for Icechunk metadata.
How serializers work:
-
Main goal is to make sure newer version of Icechunk can read metadata files created using older versions. In this way, a repository can evolve during its life. As users upgrade their Icechunk versions they don’t need to migrate their data.
-
Of course we may choose to limit backwards compatibility after certain number of versions or a time limit.
-
Performance is critical, so we cannot copy much data around during the process of serialization/deserialization
-
For serialization:
- We define a new
XSerializerfor each metadata file typeX. Example:SnapshotSerializer. - This type implement
serde::Serialize - This type holds only references to the same fields as
X - This type implements
From<&X>(notice by reference) Example:ⓘimpl<'a> From<&'a Snapshot> for SnapshotSerializer<'a> { ... } - Because the serializer only holds references it’s essentially free to call
snapshot.into()to get one. - Then this object is serialized using serde.
- We define a new
-
For deserialization:
- We define a new
XDeserializerfor each metadata file typeX. Example:SnapshotDeserializer. - This type implement
serde::Deserialize - This type holds the same fields as
Xby value XimplementsFrom<XDeserializer>(notice by value). Example:ⓘimpl From<SnapshotDeserializer> for Snapshot { ... }- Because the deserializer can be destructed and
XimplementsFrom, it’s essentially free to call obtain the original typeX - Then this new type
XDeserializeris deserialized using serde and converted withinto.
- We define a new
-
serializers.current.rsholds all the serializers and deserializers for the current version of the spec -
serializers.version_foo.rsholds all the serializers and deserializers for version foo of the spec -
The
serializersmodule root has functionsserialize_Xanddeserialize_Xthat take a spec version number and use the right (de)-serializer to do the job.
Constants§
- MAX_
APPARENT_ SIZE_ INFLATION - Upper bound on how much larger the verifier’s apparent-size counter runs than the buffer it walks, over every element type we serialize.
- MIN_
BYTES_ PER_ TABLE - Lower bound on the buffer bytes one flatbuffers table costs: a 4 byte soffset plus its 4 byte slot in the enclosing vector. Vtables are deduplicated by the builder, so they don’t count towards the floor.
- VERIFY_
THRESHOLD_ BYTES - Files at or above this size should be verified before being written.
Functions§
- deserialize_
manifest - deserialize_
repo_ info - deserialize_
snapshot - deserialize_
transaction_ log - serialize_
manifest - serialize_
repo_ info - serialize_
snapshot - serialize_
transaction_ log - verify_
buffer - Check that
buffercan be read back asfile_type.