Skip to content

Commit

Permalink
db: remove IterOptions.TableFilter
Browse files Browse the repository at this point in the history
Remove support for IterOptions.TableFilter. The earliest supported format major
version (FormatFlushableIngest introduced in v23.1) guarantees that all
sstables that predate the introduction of block-property filters have already
been compacted.
  • Loading branch information
jbowens committed Jul 30, 2024
1 parent cde3df0 commit 034fd8e
Show file tree
Hide file tree
Showing 6 changed files with 4 additions and 34 deletions.
2 changes: 0 additions & 2 deletions external_iterator.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,6 @@ func NewExternalIterWithContext(

func validateExternalIterOpts(iterOpts *IterOptions) error {
switch {
case iterOpts.TableFilter != nil:
return errors.Errorf("pebble: external iterator: TableFilter unsupported")
case iterOpts.PointKeyFilters != nil:
return errors.Errorf("pebble: external iterator: PointKeyFilters unsupported")
case iterOpts.RangeKeyFilters != nil:
Expand Down
8 changes: 1 addition & 7 deletions iterator.go
Original file line number Diff line number Diff line change
Expand Up @@ -2579,14 +2579,8 @@ func (i *Iterator) SetOptions(o *IterOptions) {
// If OnlyReadGuaranteedDurable changed, the iterator stacks are incorrect,
// improperly including or excluding memtables. Invalidate them so that
// finishInitializingIter will reconstruct them.
//
// If either the original options or the new options specify a table filter,
// we need to reconstruct the iterator stacks. If they both supply a table
// filter, we can't be certain that it's the same filter since we have no
// mechanism to compare the filter closures.
closeBoth := i.err != nil ||
o.OnlyReadGuaranteedDurable != i.opts.OnlyReadGuaranteedDurable ||
o.TableFilter != nil || i.opts.TableFilter != nil
o.OnlyReadGuaranteedDurable != i.opts.OnlyReadGuaranteedDurable

// If either options specify block property filters for an iterator stack,
// reconstruct it.
Expand Down
10 changes: 0 additions & 10 deletions iterator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1292,13 +1292,9 @@ func TestIteratorBoundsLifetimes(t *testing.T) {
return buf.String()
case "set-options":
var label string
var tableFilter bool
td.ScanArgs(t, "label", &label)
opts := iterators[label].opts
for _, arg := range td.CmdArgs {
if arg.Key == "table-filter" {
tableFilter = true
}
if arg.Key == "key-types" {
switch arg.Vals[0] {
case "points-only":
Expand All @@ -1313,9 +1309,6 @@ func TestIteratorBoundsLifetimes(t *testing.T) {
}
}
opts.LowerBound, opts.UpperBound = parseBounds(td)
if tableFilter {
opts.TableFilter = func(userProps map[string]string) bool { return false }
}
iterators[label].SetOptions(&opts)
trashBounds(opts.LowerBound, opts.UpperBound)
buf.Reset()
Expand Down Expand Up @@ -1542,9 +1535,6 @@ func iterOptionsString(o *IterOptions) string {
var buf bytes.Buffer
fmt.Fprintf(&buf, "key-types=%s, lower=%q, upper=%q",
o.KeyTypes, o.LowerBound, o.UpperBound)
if o.TableFilter != nil {
fmt.Fprintf(&buf, ", table-filter")
}
if o.OnlyReadGuaranteedDurable {
fmt.Fprintf(&buf, ", only-durable")
}
Expand Down
1 change: 0 additions & 1 deletion level_iter.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,6 @@ func (l *levelIter) init(
l.prefix = nil
l.lower = opts.LowerBound
l.upper = opts.UpperBound
l.tableOpts.TableFilter = opts.TableFilter
l.tableOpts.PointKeyFilters = opts.PointKeyFilters
if len(opts.PointKeyFilters) == 0 {
l.tableOpts.PointKeyFilters = l.filtersBuf[:0:1]
Expand Down
5 changes: 0 additions & 5 deletions options.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,6 @@ type IterOptions struct {
// boundary the iterator will return Valid()==false. Setting UpperBound
// effectively truncates the key space visible to the iterator.
UpperBound []byte
// TableFilter can be used to filter the tables that are scanned during
// iteration based on the user properties. Return true to scan the table and
// false to skip scanning. This function must be thread-safe since the same
// function can be used by multiple iterators, if the iterator is cloned.
TableFilter func(userProps map[string]string) bool
// SkipPoint may be used to skip over point keys that don't match an
// arbitrary predicate during iteration. If set, the Iterator invokes
// SkipPoint for keys encountered. If SkipPoint returns true, the iterator
Expand Down
12 changes: 3 additions & 9 deletions table_cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -423,16 +423,10 @@ func (c *tableCacheShard) releaseLoop() {
// true for ok if this table should be read by this iterator.
func (c *tableCacheShard) checkAndIntersectFilters(
v *tableCacheValue,
tableFilter func(userProps map[string]string) bool,
blockPropertyFilters []BlockPropertyFilter,
boundLimitedFilter sstable.BoundLimitedBlockPropertyFilter,
syntheticSuffix sstable.SyntheticSuffix,
) (ok bool, filterer *sstable.BlockPropertiesFilterer, err error) {
if tableFilter != nil &&
!tableFilter(v.reader.Properties.UserProperties) {
return false, nil, nil
}

if boundLimitedFilter != nil || len(blockPropertyFilters) > 0 {
filterer, err = sstable.IntersectsTable(
blockPropertyFilters,
Expand Down Expand Up @@ -549,8 +543,8 @@ func (c *tableCacheShard) newPointIter(

var ok bool
var err error
ok, filterer, err = c.checkAndIntersectFilters(v, opts.TableFilter,
pointKeyFilters, internalOpts.boundLimitedFilter, file.SyntheticSuffix)
ok, filterer, err = c.checkAndIntersectFilters(v, pointKeyFilters,
internalOpts.boundLimitedFilter, file.SyntheticSuffix)
if err != nil {
return nil, err
} else if !ok {
Expand Down Expand Up @@ -664,7 +658,7 @@ func (c *tableCacheShard) newRangeKeyIter(
// done here, rather than deferring to the block-property collector in order
// to maintain parity with point keys and the treatment of RANGEDELs.
if v.reader.Properties.NumRangeKeyDels == 0 && len(opts.RangeKeyFilters) > 0 {
ok, _, err := c.checkAndIntersectFilters(v, nil, opts.RangeKeyFilters, nil, nil /* TODO(radu) transforms.SyntheticSuffix */)
ok, _, err := c.checkAndIntersectFilters(v, opts.RangeKeyFilters, nil, nil /* TODO(radu) transforms.SyntheticSuffix */)
if err != nil {
return nil, err
} else if !ok {
Expand Down

0 comments on commit 034fd8e

Please sign in to comment.