From 63ae3c930de89af6f85229a467caa3f53cb844a2 Mon Sep 17 00:00:00 2001 From: Marcos Magueta Date: Fri, 3 Apr 2026 16:17:38 -0300 Subject: format --- lib/storable.ml | 35 +++++++++++++++-------------------- 1 file changed, 15 insertions(+), 20 deletions(-) (limited to 'lib/storable.ml') diff --git a/lib/storable.ml b/lib/storable.ml index 058773c..ec0bce2 100644 --- a/lib/storable.ml +++ b/lib/storable.ml @@ -3,7 +3,8 @@ These modules define the wire format for persisting relational engine objects to storage. Each type has to_bytes/of_bytes for serialization. - The stored formats capture only the essential data needed for reconstruction: + The stored formats capture only the essential data needed for + reconstruction: - Tuple: relation name and attribute hashes - Relation: name, schema, tuple hashes, cardinality - Database: name, relation hashes, merkle tree keys, history *) @@ -12,14 +13,12 @@ module Tuple = struct type t = { relation : string; - attributes : (string * Conventions.Hash.t) list; (* attr_name -> attr_value_hash *) + attributes : (string * Conventions.Hash.t) list; + (* attr_name -> attr_value_hash *) } - let to_bytes (st : t) : bytes = - Marshal.to_bytes st [Marshal.Closures] - - let of_bytes (b : bytes) : t = - Marshal.from_bytes b 0 + let to_bytes (st : t) : bytes = Marshal.to_bytes st [ Marshal.Closures ] + let of_bytes (b : bytes) : t = Marshal.from_bytes b 0 end (** Stored relation format for serialization *) @@ -27,30 +26,26 @@ module Relation = struct type t = { name : string; schema : Schema.t; - tree_keys : Conventions.Hash.t list; (* Merkle tree contents - tuple hashes *) + tree_keys : Conventions.Hash.t list; + (* Merkle tree contents - tuple hashes *) cardinality : Conventions.Cardinality.t; } - let to_bytes (sr : t) : bytes = - Marshal.to_bytes sr [Marshal.Closures] - - let of_bytes (b : bytes) : t = - Marshal.from_bytes b 0 + let to_bytes (sr : t) : bytes = Marshal.to_bytes sr [ Marshal.Closures ] + let of_bytes (b : bytes) : t = Marshal.from_bytes b 0 end (** Stored database format for serialization *) module Database = struct type t = { name : string; - relations : (string * Conventions.Hash.t) list; (* name -> relation_hash *) - tree_keys : Conventions.Hash.t list; (* Merkle tree contents - relation hashes *) + relations : (string * Conventions.Hash.t) list; (* name -> relation_hash *) + tree_keys : Conventions.Hash.t list; + (* Merkle tree contents - relation hashes *) history : Conventions.Hash.t list; timestamp : float; } - let to_bytes (sd : t) : bytes = - Marshal.to_bytes sd [Marshal.Closures] - - let of_bytes (b : bytes) : t = - Marshal.from_bytes b 0 + let to_bytes (sd : t) : bytes = Marshal.to_bytes sd [ Marshal.Closures ] + let of_bytes (b : bytes) : t = Marshal.from_bytes b 0 end -- cgit v1.2.3