Skip to content

Commit

Permalink
sstable: remove table property collector from test tables
Browse files Browse the repository at this point in the history
Informs #1887.
  • Loading branch information
RaduBerinde committed Jan 9, 2024
1 parent eeac388 commit f93e739
Show file tree
Hide file tree
Showing 9 changed files with 81 additions and 122 deletions.
7 changes: 2 additions & 5 deletions sstable/properties_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,8 @@ func TestPropertiesLoad(t *testing.T) {
MergerName: "nullptr",
NumDataBlocks: 14,
PrefixExtractorName: "nullptr",
PropertyCollectorNames: "[KeyCountPropertyCollector]",
UserProperties: map[string]string{
"test.key-count": "1727",
},
WholeKeyFiltering: false,
PropertyCollectorNames: "[]",
WholeKeyFiltering: false,
}

{
Expand Down
4 changes: 2 additions & 2 deletions sstable/table_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ func TestWriterRoundTrip(t *testing.T) {
fs := vfs.NewMem()
err := buildHamletTestSST(
fs, "test.sst", DefaultCompression, fp, TableFilter,
nil /* comparer */, nil /* propCollector */, blockSize, indexBlockSize,
nil /* comparer */, blockSize, indexBlockSize,
)
require.NoError(t, err)
// Check that we can read a freshly made table.
Expand Down Expand Up @@ -519,7 +519,7 @@ func TestReaderGlobalSeqNum(t *testing.T) {
func TestMetaIndexEntriesSorted(t *testing.T) {
fs := vfs.NewMem()
err := buildHamletTestSST(fs, "test.sst", DefaultCompression, nil, /* filter policy */
TableFilter, nil, nil, 4096, 4096)
TableFilter, nil, 4096, 4096)
require.NoError(t, err)
f, err := fs.Open("test.sst")
require.NoError(t, err)
Expand Down
133 changes: 48 additions & 85 deletions sstable/test_fixtures.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,6 @@ func buildHamletTestSST(
fp FilterPolicy,
ftype FilterType,
comparer *Comparer,
propCollector func() TablePropertyCollector,
blockSize int,
indexBlockSize int,
) error {
Expand All @@ -146,9 +145,6 @@ func buildHamletTestSST(
MergerName: "nullptr",
TableFormat: fixtureFormat,
}
if propCollector != nil {
writerOpts.TablePropertyCollectors = append(writerOpts.TablePropertyCollectors, propCollector)
}

w := NewWriter(objstorageprovider.NewFileWritable(f0), writerOpts)
// Use rangeDelV1Format for testing byte equality with RocksDB.
Expand Down Expand Up @@ -182,79 +178,71 @@ func buildHamletTestSST(

// TestFixtureInfo contains all metadata necessary to generate a test sstable.
type TestFixtureInfo struct {
Filename string
Compression Compression
FullKeyFilter bool
PrefixFilter bool
IndexBlockSize int
UseFixtureComparer bool
KeyCountPropertyCollector bool
Filename string
Compression Compression
FullKeyFilter bool
PrefixFilter bool
IndexBlockSize int
UseFixtureComparer bool
}

// TestFixtures contains all metadata necessary to generate the test SSTs.
var TestFixtures = []TestFixtureInfo{
{
Filename: "h.sst",
Compression: SnappyCompression,
FullKeyFilter: false,
PrefixFilter: false,
IndexBlockSize: fixtureDefaultIndexBlockSize,
UseFixtureComparer: false,
KeyCountPropertyCollector: true,
Filename: "h.sst",
Compression: SnappyCompression,
FullKeyFilter: false,
PrefixFilter: false,
IndexBlockSize: fixtureDefaultIndexBlockSize,
UseFixtureComparer: false,
},
{
Filename: "h.no-compression.sst",
Compression: NoCompression,
FullKeyFilter: false,
PrefixFilter: false,
IndexBlockSize: fixtureDefaultIndexBlockSize,
UseFixtureComparer: false,
KeyCountPropertyCollector: true,
Filename: "h.no-compression.sst",
Compression: NoCompression,
FullKeyFilter: false,
PrefixFilter: false,
IndexBlockSize: fixtureDefaultIndexBlockSize,
UseFixtureComparer: false,
},
{
Filename: "h.table-bloom.sst",
Compression: SnappyCompression,
FullKeyFilter: true,
PrefixFilter: false,
IndexBlockSize: fixtureDefaultIndexBlockSize,
UseFixtureComparer: false,
KeyCountPropertyCollector: false,
Filename: "h.table-bloom.sst",
Compression: SnappyCompression,
FullKeyFilter: true,
PrefixFilter: false,
IndexBlockSize: fixtureDefaultIndexBlockSize,
UseFixtureComparer: false,
},
{
Filename: "h.table-bloom.no-compression.sst",
Compression: NoCompression,
FullKeyFilter: true,
PrefixFilter: false,
IndexBlockSize: fixtureDefaultIndexBlockSize,
UseFixtureComparer: false,
KeyCountPropertyCollector: false,
Filename: "h.table-bloom.no-compression.sst",
Compression: NoCompression,
FullKeyFilter: true,
PrefixFilter: false,
IndexBlockSize: fixtureDefaultIndexBlockSize,
UseFixtureComparer: false,
},
{
Filename: "h.table-bloom.no-compression.prefix_extractor.no_whole_key_filter.sst",
Compression: NoCompression,
FullKeyFilter: false,
PrefixFilter: true,
IndexBlockSize: fixtureDefaultIndexBlockSize,
UseFixtureComparer: true,
KeyCountPropertyCollector: false,
Filename: "h.table-bloom.no-compression.prefix_extractor.no_whole_key_filter.sst",
Compression: NoCompression,
FullKeyFilter: false,
PrefixFilter: true,
IndexBlockSize: fixtureDefaultIndexBlockSize,
UseFixtureComparer: true,
},
{
Filename: "h.no-compression.two_level_index.sst",
Compression: NoCompression,
FullKeyFilter: false,
PrefixFilter: false,
IndexBlockSize: fixtureSmallIndexBlockSize,
UseFixtureComparer: false,
KeyCountPropertyCollector: true,
Filename: "h.no-compression.two_level_index.sst",
Compression: NoCompression,
FullKeyFilter: false,
PrefixFilter: false,
IndexBlockSize: fixtureSmallIndexBlockSize,
UseFixtureComparer: false,
},
{
Filename: "h.zstd-compression.sst",
Compression: ZstdCompression,
FullKeyFilter: false,
PrefixFilter: false,
IndexBlockSize: fixtureDefaultIndexBlockSize,
UseFixtureComparer: false,
KeyCountPropertyCollector: true,
Filename: "h.zstd-compression.sst",
Compression: ZstdCompression,
FullKeyFilter: false,
PrefixFilter: false,
IndexBlockSize: fixtureDefaultIndexBlockSize,
UseFixtureComparer: false,
},
}

Expand All @@ -268,17 +256,10 @@ func (tf TestFixtureInfo) Build(fs vfs.FS, filename string) error {
if tf.UseFixtureComparer {
comparer = fixtureComparer
}
var propCollector func() TablePropertyCollector
if tf.KeyCountPropertyCollector {
propCollector = func() TablePropertyCollector {
return &keyCountPropertyCollector{}
}
}

return buildHamletTestSST(
fs, filename, tf.Compression, fp, base.TableFilter,
comparer,
propCollector,
fixtureBlockSize,
tf.IndexBlockSize,
)
Expand All @@ -289,24 +270,6 @@ const fixtureSmallIndexBlockSize = 128
const fixtureBlockSize = 2048
const fixtureFormat = TableFormatPebblev1

type keyCountPropertyCollector struct {
count int
}

func (c *keyCountPropertyCollector) Add(key InternalKey, value []byte) error {
c.count++
return nil
}

func (c *keyCountPropertyCollector) Finish(userProps map[string]string) error {
userProps["test.key-count"] = fmt.Sprint(c.count)
return nil
}

func (c *keyCountPropertyCollector) Name() string {
return "KeyCountPropertyCollector"
}

var fixtureComparer = func() *Comparer {
c := *base.DefaultComparer
// NB: this is named as such only to match the built-in RocksDB comparer.
Expand Down
Binary file modified sstable/testdata/h.no-compression.sst
Binary file not shown.
Binary file modified sstable/testdata/h.no-compression.two_level_index.sst
Binary file not shown.
Binary file modified sstable/testdata/h.sst
Binary file not shown.
Binary file modified sstable/testdata/h.zstd-compression.sst
Binary file not shown.
59 changes: 29 additions & 30 deletions tool/testdata/sstable_layout
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ h.sst
13752 data (156)
13913 index (245)
14163 range-del (421)
14589 properties (582)
15176 meta-index (61)
15242 footer (53)
15295 EOF
14589 properties (536)
15130 meta-index (61)
15196 footer (53)
15249 EOF

sstable layout
../sstable/testdata/h.table-bloom.no-compression.sst
Expand Down Expand Up @@ -76,10 +76,10 @@ h.no-compression.two_level_index.sst
27047 index (95)
27147 top-index (70)
27222 range-del (421)
27648 properties (628)
28281 meta-index (63)
28349 footer (53)
28402 EOF
27648 properties (582)
28235 meta-index (63)
28303 footer (53)
28356 EOF

sstable layout
-v
Expand Down Expand Up @@ -3744,7 +3744,7 @@ h.no-compression.two_level_index.sst
27631 [restart 27523]
27635 [restart 27546]
27643 [trailer compression=none checksum=0xb93b31c5]
27648 properties (628)
27648 properties (582)
27648 rocksdb.block.based.table.index.type (43) [restart]
27691 rocksdb.block.based.table.prefix.filtering (20)
27711 rocksdb.block.based.table.whole.key.filtering (23)
Expand All @@ -3764,27 +3764,26 @@ h.no-compression.two_level_index.sst
28081 rocksdb.num.entries (12)
28093 rocksdb.num.range-deletions (19)
28112 rocksdb.prefix.extractor.name (31)
28143 rocksdb.property.collectors (47)
28190 rocksdb.raw.key.size (18)
28208 rocksdb.raw.value.size (15)
28223 rocksdb.top-level.index.size (24)
28247 test.key-count (21)
28268 [restart 27648]
28276 [trailer compression=none checksum=0xdddd20b2]
28281 meta-index (63)
28281 rocksdb.properties block:27648/628 [restart]
28307 rocksdb.range_del block:27222/421 [restart]
28332 [restart 28281]
28336 [restart 28307]
28344 [trailer compression=none checksum=0xc1962fe1]
28349 footer (53)
28349 checksum type: crc32c
28350 meta: offset=28281, length=63
28354 index: offset=27147, length=70
28358 [padding]
28390 version: 1
28394 magic number: 0xf09faab3f09faab3
28402 EOF
28143 rocksdb.property.collectors (22)
28165 rocksdb.raw.key.size (18)
28183 rocksdb.raw.value.size (15)
28198 rocksdb.top-level.index.size (24)
28222 [restart 27648]
28230 [trailer compression=none checksum=0x9414996]
28235 meta-index (63)
28235 rocksdb.properties block:27648/582 [restart]
28261 rocksdb.range_del block:27222/421 [restart]
28286 [restart 28235]
28290 [restart 28261]
28298 [trailer compression=none checksum=0x9e135f62]
28303 footer (53)
28303 checksum type: crc32c
28304 meta: offset=28235, length=63
28308 index: offset=27147, length=70
28312 [padding]
28344 version: 1
28348 magic number: 0xf09faab3f09faab3
28356 EOF

sstable layout
-v
Expand Down
Binary file modified tool/testdata/sstable_properties
Binary file not shown.

0 comments on commit f93e739

Please sign in to comment.