Skip to content

Quickfix for situations where Value hash length 0 #387

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion src/log_file.ml
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,17 @@ module Make (IO : Io.S) (Key : Data.Key) (Value : Data.Value) = struct
let len = Entry.encoded_size in
let r = IO.read t.io ~off ~len scratch.buffer in
assert (r = Entry.encoded_size);
Entry.decode (Bytes.unsafe_to_string scratch.buffer) 0
let s =
if Value.encoded_size = 0 then
(* Quickfix for a situation where [Key.decode] kept a pointer to [s]
when [Value.encoded_size = 0]. This led to a bug where some entries
dissapeared post-merge.

A proper solution will be implemented in the future. *)
Bytes.to_string scratch.buffer
else Bytes.unsafe_to_string scratch.buffer
in
Entry.decode s 0

let elt_index t key =
(* NOTE: we use the _uppermost_ bits of the key hash to index the bucket
Expand Down