Crdt.Model_codec_indexed
crdt · API reference
Indexed document codec (flat map by timestamp)
Indexed document codec.
The indexed format stores nodes as a flat map keyed by timestamp string. This is useful for:
- Incremental sync (fetch individual nodes by ID)
- Efficient lookup of specific nodes
- Partial document loading Format:
{
"clock": [[sid, time], ...],
"root": "sid.time", // Timestamp string for root node
"nodes": {
"sid.time": {...node data...},
...
}
}Node formats in the map:
- con:
{"t": "con", "v": value} - val:
{"t": "val", "r": "sid.time"}or{"t": "val"}if empty - obj:
{"t": "obj", "m": {"key": "sid.time", ...}} - vec:
{"t": "vec", "s": ["sid.time" or null, ...]} - str:
{"t": "str", "c": [[sid,time,value_or_span], ...]} - bin:
{"t": "bin", "c": [[sid,time,value_or_span], ...]} - arr:
{"t": "arr", "c": [[sid,time,ref_or_span], ...]}
module J = Simdjsont.Jsonval ts_to_string : Clock.timestamp -> stringval ts_of_string : string -> Clock.timestamp optionval encode_timestamp : Clock.timestamp -> J.tval decode_timestamp : J.t -> Clock.timestamp optionval encode_clock : Clock.clock_vector -> J.tval decode_clock : J.t -> Clock.clock_vector optionval encode_value : Value.t -> J.tval decode_value : J.t -> Value.tval encode_node : Node.t -> J.tval encode : Model.t -> J.tval encode_string : ?minify:bool -> Model.t -> stringval encode_bigstring :
?minify:bool ->
Model.t ->
(char, Bigarray.int8_unsigned_elt, Bigarray.c_layout) Bigarray.Array1.t * intval get_member : string -> (string * J.t) list -> J.t optionval decode_node : Model.t -> J.t -> Clock.timestamp -> Node.t optionval link_val_ref : 'a -> J.t -> Node.t -> unitval link_obj_entries : 'a -> J.t -> Node.t -> unitval link_vec_slots : 'a -> J.t -> Node.t -> unitval link_arr_elements : 'a -> J.t -> Node.t -> unitval decode : J.t -> Model.t optionval decode_string : string -> Model.t optionval decode_bigstring :
(char, Bigarray.int8_unsigned_elt, Bigarray.c_layout) Bigarray.Array1.t ->
len:int ->
Model.t optionval get_node_json : J.t -> Clock.timestamp -> J.t optionval get_node_ids : J.t -> Clock.timestamp list