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.