Fixed a bug with incorrect offsets populating the trie (#82)

This commit is contained in:
James Mills 2019-09-02 19:44:11 +10:00 committed by GitHub
parent 0338755f8c
commit 50d3971e86
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -356,6 +356,7 @@ func (b *Bitcask) reopen() error {
}
} else {
for i, df := range datafiles {
var offset int64
for {
e, n, err := df.Read()
if err != nil {
@ -368,11 +369,13 @@ func (b *Bitcask) reopen() error {
// Tombstone value (deleted key)
if len(e.Value) == 0 {
t.Delete(e.Key)
offset += n
continue
}
item := internal.Item{FileID: ids[i], Offset: e.Offset, Size: n}
item := internal.Item{FileID: ids[i], Offset: offset, Size: n}
t.Insert(e.Key, item)
offset += n
}
}
}