Skip to content

Commit cebacb9

Browse files
committed
db: remove FilterType option
Remove this legacy field.
1 parent 26371ea commit cebacb9

File tree

16 files changed

+24
-102
lines changed

16 files changed

+24
-102
lines changed

bloom/bloom.go

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ package bloom // import "github.com/cockroachdb/pebble/bloom"
77

88
import (
99
"encoding/binary"
10-
"fmt"
1110
"sync"
1211

1312
"github.com/cockroachdb/pebble/internal/base"
@@ -228,21 +227,11 @@ func (p FilterPolicy) Name() string {
228227
}
229228

230229
// MayContain implements the pebble.FilterPolicy interface.
231-
func (p FilterPolicy) MayContain(ftype base.FilterType, f, key []byte) bool {
232-
switch ftype {
233-
case base.TableFilter:
234-
return tableFilter(f).MayContain(key)
235-
default:
236-
panic(fmt.Sprintf("unknown filter type: %v", ftype))
237-
}
230+
func (p FilterPolicy) MayContain(f, key []byte) bool {
231+
return tableFilter(f).MayContain(key)
238232
}
239233

240234
// NewWriter implements the pebble.FilterPolicy interface.
241-
func (p FilterPolicy) NewWriter(ftype base.FilterType) base.FilterWriter {
242-
switch ftype {
243-
case base.TableFilter:
244-
return newTableFilterWriter(int(p))
245-
default:
246-
panic(fmt.Sprintf("unknown filter type: %v", ftype))
247-
}
235+
func (p FilterPolicy) NewWriter() base.FilterWriter {
236+
return newTableFilterWriter(int(p))
248237
}

bloom/bloom_test.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import (
99
"strings"
1010
"testing"
1111

12-
"github.com/cockroachdb/pebble/internal/base"
1312
"github.com/stretchr/testify/require"
1413
)
1514

@@ -37,7 +36,7 @@ func (f tableFilter) String() string {
3736
}
3837

3938
func newTableFilter(bitsPerKey int, keys ...[]byte) tableFilter {
40-
w := FilterPolicy(bitsPerKey).NewWriter(base.TableFilter)
39+
w := FilterPolicy(bitsPerKey).NewWriter()
4140
for _, key := range keys {
4241
w.AddKey(key)
4342
}
@@ -210,7 +209,7 @@ func BenchmarkBloomFilter(b *testing.B) {
210209
b.ResetTimer()
211210
policy := FilterPolicy(10)
212211
for i := 0; i < b.N; i++ {
213-
w := policy.NewWriter(base.TableFilter)
212+
w := policy.NewWriter()
214213
for _, key := range keys {
215214
w.AddKey(key)
216215
}

cmd/pebble/db.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,6 @@ func newPebbleDB(dir string) DB {
100100
l.BlockSize = 32 << 10 // 32 KB
101101
l.IndexBlockSize = 256 << 10 // 256 KB
102102
l.FilterPolicy = bloom.FilterPolicy(10)
103-
l.FilterType = pebble.TableFilter
104103
}
105104
opts.Levels[6].FilterPolicy = pebble.NoFilterPolicy
106105
opts.FlushSplitBytes = opts.TargetFileSizes[0]

external_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,6 @@ func buildSeparatedValuesDB(
208208
o.Levels[0].BlockSize = 32 << 10 // 32 KB
209209
o.Levels[0].IndexBlockSize = 256 << 10 // 256 KB
210210
o.Levels[0].FilterPolicy = bloom.FilterPolicy(10)
211-
o.Levels[0].FilterType = pebble.TableFilter
212211
db, err := pebble.Open("", o)
213212
require.NoError(tb, err)
214213

internal/base/options.go

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -12,22 +12,6 @@ const (
1212
SizeClassAwareBlockSizeThreshold = 60
1313
)
1414

15-
// FilterType is the level at which to apply a filter: block or table.
16-
type FilterType int
17-
18-
// The available filter types.
19-
const (
20-
TableFilter FilterType = iota
21-
)
22-
23-
func (t FilterType) String() string {
24-
switch t {
25-
case TableFilter:
26-
return "table"
27-
}
28-
return "unknown"
29-
}
30-
3115
// FilterWriter provides an interface for creating filter blocks. See
3216
// FilterPolicy for more details about filters.
3317
type FilterWriter interface {
@@ -59,20 +43,20 @@ type FilterPolicy interface {
5943
// MayContain returns whether the encoded filter may contain given key.
6044
// False positives are possible, where it returns true for keys not in the
6145
// original set.
62-
MayContain(ftype FilterType, filter, key []byte) bool
46+
MayContain(filter, key []byte) bool
6347

6448
// NewWriter creates a new FilterWriter.
65-
NewWriter(ftype FilterType) FilterWriter
49+
NewWriter() FilterWriter
6650
}
6751

6852
// NoFilterPolicy implements the "none" filter policy.
6953
var NoFilterPolicy FilterPolicy = noFilter{}
7054

7155
type noFilter struct{}
7256

73-
func (noFilter) Name() string { return "none" }
74-
func (noFilter) MayContain(ftype FilterType, filter, key []byte) bool { return true }
75-
func (noFilter) NewWriter(ftype FilterType) FilterWriter { panic("not implemented") }
57+
func (noFilter) Name() string { return "none" }
58+
func (noFilter) MayContain(filter, key []byte) bool { return true }
59+
func (noFilter) NewWriter() FilterWriter { panic("not implemented") }
7660

7761
// BlockPropertyFilter is used in an Iterator to filter sstables and blocks
7862
// within the sstable. It should not maintain any per-sstable state, and must

merging_iter_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -575,7 +575,6 @@ func buildLevelsForMergingIterSeqSeek(
575575
}
576576
if writeBloomFilters {
577577
writerOptions.FilterPolicy = filterPolicy
578-
writerOptions.FilterType = base.TableFilter
579578
}
580579
if forceTwoLevelIndex {
581580
if i == 0 && j == 0 {

options.go

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -49,14 +49,6 @@ const (
4949
type SpanPolicy = base.SpanPolicy
5050
type ValueStoragePolicyAdjustment = base.ValueStoragePolicyAdjustment
5151

52-
// FilterType exports the base.FilterType type.
53-
type FilterType = base.FilterType
54-
55-
// Exported TableFilter constants.
56-
const (
57-
TableFilter = base.TableFilter
58-
)
59-
6052
// FilterWriter exports the base.FilterWriter type.
6153
type FilterWriter = base.FilterWriter
6254

@@ -463,10 +455,6 @@ type LevelOptions struct {
463455
// the previous level for all other levels.
464456
FilterPolicy FilterPolicy
465457

466-
// FilterType is a legacy field. The default and only possible value is
467-
// TableFilter.
468-
FilterType FilterType
469-
470458
// IndexBlockSize is the target uncompressed size in bytes of each index
471459
// block. When the index block size is larger than this target, two-level
472460
// indexes are automatically enabled. Setting this option to a large value
@@ -1832,7 +1820,7 @@ func (o *Options) String() string {
18321820
fmt.Fprintf(&buf, " block_size_threshold=%d\n", l.BlockSizeThreshold)
18331821
fmt.Fprintf(&buf, " compression=%s\n", l.Compression().Name)
18341822
fmt.Fprintf(&buf, " filter_policy=%s\n", l.FilterPolicy.Name())
1835-
fmt.Fprintf(&buf, " filter_type=%s\n", l.FilterType)
1823+
fmt.Fprintf(&buf, " filter_type=table\n")
18361824
fmt.Fprintf(&buf, " index_block_size=%d\n", l.IndexBlockSize)
18371825
fmt.Fprintf(&buf, " target_file_size=%d\n", o.TargetFileSizes[i])
18381826
}
@@ -2350,7 +2338,6 @@ func (o *Options) Parse(s string, hooks *ParseHooks) error {
23502338
case "filter_type":
23512339
switch value {
23522340
case "table":
2353-
l.FilterType = TableFilter
23542341
default:
23552342
// Tolerate unknown options, but log them.
23562343
if o.Logger != nil {
@@ -2629,7 +2616,6 @@ func (o *Options) MakeWriterOptions(level int, format sstable.TableFormat) sstab
26292616
writerOpts.BlockSizeThreshold = levelOpts.BlockSizeThreshold
26302617
writerOpts.Compression = levelOpts.Compression()
26312618
writerOpts.FilterPolicy = levelOpts.FilterPolicy
2632-
writerOpts.FilterType = levelOpts.FilterType
26332619
writerOpts.IndexBlockSize = levelOpts.IndexBlockSize
26342620
return writerOpts
26352621
}

sstable/colblk_writer.go

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import (
88
"bytes"
99
"context"
1010
"encoding/binary"
11-
"fmt"
1211
"math"
1312
"slices"
1413
"sync"
@@ -151,12 +150,7 @@ func newColumnarWriter(
151150
w.valueBlock = valblk.NewWriter(flushGovernor, &w.layout.physBlockMaker, func(compressedSize int) {})
152151
}
153152
if o.FilterPolicy != base.NoFilterPolicy {
154-
switch o.FilterType {
155-
case TableFilter:
156-
w.filterBlock = newTableFilterWriter(o.FilterPolicy)
157-
default:
158-
panic(fmt.Sprintf("unknown filter type: %v", o.FilterType))
159-
}
153+
w.filterBlock = newTableFilterWriter(o.FilterPolicy)
160154
}
161155

162156
numBlockPropertyCollectors := len(o.BlockPropertyCollectors)

sstable/filter.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ func newTableFilterReader(policy FilterPolicy, metrics *FilterMetricsTracker) *t
5656
}
5757

5858
func (f *tableFilterReader) mayContain(data, key []byte) bool {
59-
mayContain := f.policy.MayContain(TableFilter, data, key)
59+
mayContain := f.policy.MayContain(data, key)
6060
if f.metrics != nil {
6161
if mayContain {
6262
f.metrics.misses.Add(1)
@@ -77,7 +77,7 @@ type tableFilterWriter struct {
7777
func newTableFilterWriter(policy FilterPolicy) *tableFilterWriter {
7878
return &tableFilterWriter{
7979
policy: policy,
80-
writer: policy.NewWriter(TableFilter),
80+
writer: policy.NewWriter(),
8181
}
8282
}
8383

sstable/options.go

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,6 @@ var ignoredInternalProperties = map[string]struct{}{
4141
"rocksdb.compression_options": {},
4242
}
4343

44-
// FilterType exports the base.FilterType type.
45-
type FilterType = base.FilterType
46-
47-
// Exported TableFilter constants.
48-
const (
49-
TableFilter = base.TableFilter
50-
)
51-
5244
// FilterWriter exports the base.FilterWriter type.
5345
type FilterWriter = base.FilterWriter
5446

@@ -199,15 +191,6 @@ type WriterOptions struct {
199191
// The default value is NoFilterPolicy.
200192
FilterPolicy FilterPolicy
201193

202-
// FilterType defines whether an existing filter policy is applied at a
203-
// block-level or table-level. Block-level filters use less memory to create,
204-
// but are slower to access as a check for the key in the index must first be
205-
// performed to locate the filter block. A table-level filter will require
206-
// memory proportional to the number of keys in an sstable to create, but
207-
// avoids the index lookup when determining if a key is present. Table-level
208-
// filters should be preferred except under constrained memory situations.
209-
FilterType FilterType
210-
211194
// IndexBlockSize is the target uncompressed size in bytes of each index
212195
// block. When the index block size is larger than this target, two-level
213196
// indexes are automatically enabled. Setting this option to a large value

0 commit comments

Comments
 (0)