Skip to content

Commit

Permalink
Store hashes
Browse files Browse the repository at this point in the history
  • Loading branch information
firelizzard18 committed Jun 13, 2024
1 parent 07a2ae3 commit cc1bf9d
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 5 deletions.
4 changes: 2 additions & 2 deletions pkg/database/keyvalue/block/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ func Open(path string, options ...Option) (_ *Database, err error) {
return nil, fmt.Errorf("%v is corrupted", f.file.Name())
}

records.Put(e.Key.Hash(), recordLocation{
records.Put(e.KeyHash, recordLocation{
file: uint(fileNo),
block: *block,
header: start + 2, // The header has a 2 byte length prefix
Expand Down Expand Up @@ -418,7 +418,7 @@ func (d *Database) commit(view *recordsView, entries map[[32]byte]memory.Entry)
}

// Write the entry
n, err := writeEntry(f.file, &recordEntry{Key: e.Key, Length: l})
n, err := writeEntry(f.file, &recordEntry{Key: e.Key, Length: l, KeyHash: e.Key.Hash()})
if err != nil {
return err
}
Expand Down
2 changes: 2 additions & 0 deletions pkg/database/keyvalue/block/schema.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ entry:
fields:
- name: Key
type: '*record.Key'
- name: KeyHash
type: hash
- name: Length
type: int

Expand Down
4 changes: 4 additions & 0 deletions pkg/database/keyvalue/block/schema_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 5 additions & 3 deletions pkg/database/keyvalue/block/types_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit cc1bf9d

Please sign in to comment.