Skip to content

Commit

Permalink
sstable: remove unnecessary loop while identifying filter block
Browse files Browse the repository at this point in the history
When opening an sstable and reading the metaindex, we loop over the known
filters looking for a block with a matching name. Previously there was an inner
loop that statically only ever had one iteration. This inner loop was a vestige
from early Pebble's support for 'block-based' bloom filters. There's only ever
been a single filter type since #32.
  • Loading branch information
jbowens committed Sep 5, 2024
1 parent 1c5e99f commit 9095323
Showing 1 changed file with 3 additions and 23 deletions.
26 changes: 3 additions & 23 deletions sstable/reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -559,29 +559,9 @@ func (r *Reader) readMetaindex(
}

for name, fp := range filters {
types := []struct {
ftype FilterType
prefix string
}{
{TableFilter, "fullfilter."},
}
var done bool
for _, t := range types {
if bh, ok := meta[t.prefix+name]; ok {
r.filterBH = bh

switch t.ftype {
case TableFilter:
r.tableFilter = newTableFilterReader(fp, r.filterMetricsTracker)
default:
return base.CorruptionErrorf("unknown filter type: %v", errors.Safe(t.ftype))
}

done = true
break
}
}
if done {
if bh, ok := meta["fullfilter."+name]; ok {
r.filterBH = bh
r.tableFilter = newTableFilterReader(fp, r.filterMetricsTracker)
break
}
}
Expand Down

0 comments on commit 9095323

Please sign in to comment.