Skip to content

Commit

Permalink
db: refactor Reader.Get
Browse files Browse the repository at this point in the history
This commit refactors the implementation of getIter to be a little more
understandable and avoid the unnecessary use of levelIter. Current supported
format major versions guarantee that a user key is not split across sstables
within a level. This ensures that Get (which only retrieves one individual user
key) need only consult 1 sstable per level.

This is somewhat motivated by #2863. Removing getIter's dependency on levelIter
will make that refactor easier.
  • Loading branch information
jbowens committed Apr 12, 2024
1 parent cf40ae7 commit e766263
Show file tree
Hide file tree
Showing 5 changed files with 245 additions and 156 deletions.
22 changes: 16 additions & 6 deletions db.go
Original file line number Diff line number Diff line change
Expand Up @@ -557,15 +557,25 @@ func (d *DB) getInternal(key []byte, b *Batch, s *Snapshot) ([]byte, io.Closer,

get := &buf.get
*get = getIter{
logger: d.opts.Logger,
comparer: d.opts.Comparer,
newIters: d.newIters,
snapshot: seqNum,
key: key,
batch: b,
mem: readState.memtables,
l0: readState.current.L0SublevelFiles,
version: readState.current,
iterOpts: IterOptions{
// TODO(sumeer): replace with a parameter provided by the caller.
CategoryAndQoS: sstable.CategoryAndQoS{
Category: "pebble-get",
QoSLevel: sstable.LatencySensitiveQoSLevel,
},
logger: d.opts.Logger,
snapshotForHideObsoletePoints: seqNum,
},
key: key,
// Compute the key prefix for bloom filtering.
prefix: key[:d.opts.Comparer.Split(key)],
batch: b,
mem: readState.memtables,
l0: readState.current.L0SublevelFiles,
version: readState.current,
}

// Strip off memtables which cannot possibly contain the seqNum being read
Expand Down

0 comments on commit e766263

Please sign in to comment.