(** Core types for Lithos *) type ro type rw type page_id = int64 type metadata = { version : int ; page_size : int ; root_bucket : page_id option } type txn_state = | Active | Committed | Rolled_back type key = bytes type value = (char, Bigarray.int8_unsigned_elt, Bigarray.c_layout) Bigarray.Array1.t let key_of_string s = Bytes.of_string s let string_of_key k = Bytes.to_string k let value_of_bytes b = let len = Bytes.length b in let arr = Bigarray.Array1.create Bigarray.char Bigarray.c_layout len in for i = 0 to len - 1 do Bigarray.Array1.set arr i (Bytes.get b i) done; arr ;; let bytes_of_value v = let len = Bigarray.Array1.dim v in let b = Bytes.create len in for i = 0 to len - 1 do Bytes.set b i (Bigarray.Array1.get v i) done; b ;; let value_of_string s = value_of_bytes (Bytes.of_string s) let string_of_value v = Bytes.to_string (bytes_of_value v)