Persistent store with Git semantics: lazy reads, delayed writes, content-addressing
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

irmin: add Heap.layer for overlay heaps

Reads fall through from top to bottom; writes and caches go to top.
This is the building block for lazy remote navigation: layer a local
cache over a remote heap so cursors transparently fetch on miss.

+22 -3
+1 -1
lib/dune
··· 2 2 (name irmin) 3 3 (public_name irmin) 4 4 (modules hash heap schema irmin) 5 - (libraries eio fpath digestif fmt logs bytesrw)) 5 + (libraries eio fpath digestif fmt logs bytesrw merge3))
+16
lib/heap.ml
··· 110 110 close = (fun () -> ()); 111 111 to_seq = (fun () -> List.to_seq blocks); 112 112 } 113 + 114 + let layer top bottom = 115 + { 116 + top with 117 + find = 118 + (fun h -> 119 + match top.find h with 120 + | Some _ as r -> r 121 + | None -> ( 122 + match bottom.find h with 123 + | Some data as r -> 124 + top.put h data; 125 + r 126 + | None -> None)); 127 + mem = (fun h -> top.mem h || bottom.mem h); 128 + }
+5 -2
lib/heap.mli
··· 89 89 val of_list : equal:('h -> 'h -> bool) -> ('h * 'v) list -> ('h, 'v, 'b) t 90 90 (** [of_list ~equal blocks] creates a heap backed by [blocks]. *) 91 91 92 + val layer : ('h, 'v, _) t -> ('h, 'v, _) t -> ('h, 'v, _) t 93 + (** [layer top bottom] reads from [top] first, then [bottom] on miss. Writes go 94 + to [top]. Found blocks from [bottom] are cached in [top]. *) 95 + 92 96 val to_seq : ('h, 'v, _) t -> ('h * 'v) Seq.t 93 - (** [to_seq heap] enumerates the heap's blocks. For proof subheaps (created by 94 - {!of_list}), returns all blocks. For backend heaps, returns [Seq.empty]. *) 97 + (** [to_seq heap] enumerates the heap's blocks. *)