Tree shaped append-only persistent storage for commit entries.
The commit information is also recorded to the Plebeia context file as a linked list, but it is not random-accessible and very slow.
Commit_tree provides a fast random access from the commit hash to its Commit.t index in the context and the parent commit hash.
XXX Bug: currently the tree never free entries on memory. This may cause unexpected memory usage. 57.65 MiB for 160,000 commits.
val create : ?length:Index.t -> ?resize_step_bytes:int -> string -> t Lwt.t
Create a new empty commit tree file
val open_ :
?resize_step_bytes:int ->
mode:Storage.mode ->
string ->
t option Lwt.t
If the file exists, load its latest commit tree. Otherwise, returns None
val offline_gc :
?resize_step_bytes:int ->
string ->
(unit, Error.t) Stdlib.result Lwt.t
gc fn
replaces the commit tree file fn
by a new one only with the latest commit found in fn
.
The original file is backed up as fn ^ ".old"
. If the backup file already exists, it is overwritten.
This GC is offline. Never call this function when fn
is being used.
val write : t -> (unit, Error.t) Stdlib.result
Write the modifications to t
to the disk.
val commit : t -> unit Lwt.t
val flush : t -> unit Lwt.t
val update_reader : t -> t Lwt.t
Update t
to the latest commit tree on the disk.
The reader process of the commit tree must call this function time to time to get the updates by the writer.
val may_forget : t -> t option
Forget the on-memory cache of t
. This fails and returns None
if t
has unsaved updates.
val close : t -> (unit, Error.t) Stdlib.result Lwt.t
Close t
.
In Writer mode, it saves before closing. Save errors do not prevent the closing.
If a binding already exists, it is overwritten.
children t
returns a function to query children of the given hash.
Note that children t
takes some time since it traverses the whole commit tree.
Get the genesis commit hashes and the entries, which have no parent.
This function traverses the whole commit tree, therefore inefficient.
Folding. Parent commits are folded earlier than their children
Note that ordered_fold
takes some time since it traverse the whole commit tree.
test and debugging purpose