Skip to content

Commit

Permalink
sstable: capture elided prefix in a prop
Browse files Browse the repository at this point in the history
  • Loading branch information
dt committed Jan 23, 2024
1 parent b5139bb commit 3b862af
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 9 deletions.
7 changes: 6 additions & 1 deletion sstable/properties.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,9 @@ type Properties struct {
CompressionOptions string `prop:"rocksdb.compression_options"`
// The total size of all data blocks.
DataSize uint64 `prop:"rocksdb.data.size"`
// ElidedPrefix is the byte prefix, if any, that was elided from every key and
// key span during the construction of the sstable.
ElidedPrefix string `prop:"pebble.elided_prefix"`
// The external sstable version format. Version 2 is the one RocksDB has been
// using since 5.13. RocksDB only uses the global sequence number for an
// sstable if this property has been set.
Expand Down Expand Up @@ -428,7 +431,9 @@ func (p *Properties) save(tblFormat TableFormat, w *rawBlockWriter) {
p.saveUvarint(m, unsafe.Offsetof(p.ValueBlocksSize), p.ValueBlocksSize)
}
p.saveBool(m, unsafe.Offsetof(p.WholeKeyFiltering), p.WholeKeyFiltering)

if p.ElidedPrefix != "" {
p.saveString(m, unsafe.Offsetof(p.ElidedPrefix), p.ElidedPrefix)
}
if tblFormat < TableFormatPebblev1 {
m["rocksdb.column.family.id"] = binary.AppendUvarint([]byte(nil), math.MaxInt32)
m["rocksdb.fixed.key.length"] = []byte{0x00}
Expand Down
4 changes: 3 additions & 1 deletion sstable/testdata/writer
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ layout
821 footer (53)
874 EOF

build elide-prefix=foo_
build elide-prefix=foo_ props=(elided)
foo_a.SET.1:a
foo_b.DEL.2:
foo_c.MERGE.3:c
Expand All @@ -386,3 +386,5 @@ point: [a#1,1-h#7,2]
rangedel: [d#4,15-j#72057594037927935,15]
rangekey: [j#9,19-m#72057594037927935,21]
seqnums: [1-11]
props "elided":
pebble.elided_prefix: foo_
1 change: 1 addition & 0 deletions sstable/writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -2303,6 +2303,7 @@ func NewWriter(writable objstorage.Writable, o WriterOptions, extraOpts ...Write
w.props.MergerName = o.MergerName
w.props.PropertyCollectorNames = "[]"
w.props.ExternalFormatVersion = rocksDBExternalFormatVersion
w.props.ElidedPrefix = string(o.ElidePrefix)

if len(o.BlockPropertyCollectors) > 0 || w.tableFormat >= TableFormatPebblev4 {
var buf bytes.Buffer
Expand Down
4 changes: 2 additions & 2 deletions testdata/event_listener
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ Zombie tables: 0 (0B)
Backing tables: 0 (0B)
Virtual tables: 0 (0B)
Block cache: 6 entries (1.1KB) hit rate: 11.1%
Table cache: 1 entries (808B) hit rate: 40.0%
Table cache: 1 entries (824B) hit rate: 40.0%
Secondary cache: 0 entries (0B) hit rate: 0.0%
Snapshots: 0 earliest seq num: 0
Table iters: 0
Expand Down Expand Up @@ -321,7 +321,7 @@ Zombie tables: 0 (0B)
Backing tables: 0 (0B)
Virtual tables: 0 (0B)
Block cache: 12 entries (2.3KB) hit rate: 14.3%
Table cache: 1 entries (808B) hit rate: 50.0%
Table cache: 1 entries (824B) hit rate: 50.0%
Secondary cache: 0 entries (0B) hit rate: 0.0%
Snapshots: 0 earliest seq num: 0
Table iters: 0
Expand Down
2 changes: 1 addition & 1 deletion testdata/ingest
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ Zombie tables: 0 (0B)
Backing tables: 0 (0B)
Virtual tables: 0 (0B)
Block cache: 6 entries (1.2KB) hit rate: 35.7%
Table cache: 1 entries (808B) hit rate: 50.0%
Table cache: 1 entries (824B) hit rate: 50.0%
Secondary cache: 0 entries (0B) hit rate: 0.0%
Snapshots: 0 earliest seq num: 0
Table iters: 0
Expand Down
8 changes: 4 additions & 4 deletions testdata/metrics
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ Zombie tables: 0 (0B)
Backing tables: 0 (0B)
Virtual tables: 0 (0B)
Block cache: 3 entries (556B) hit rate: 0.0%
Table cache: 1 entries (808B) hit rate: 0.0%
Table cache: 1 entries (824B) hit rate: 0.0%
Secondary cache: 0 entries (0B) hit rate: 0.0%
Snapshots: 0 earliest seq num: 0
Table iters: 1
Expand Down Expand Up @@ -201,7 +201,7 @@ Zombie tables: 1 (661B)
Backing tables: 0 (0B)
Virtual tables: 0 (0B)
Block cache: 3 entries (556B) hit rate: 42.9%
Table cache: 1 entries (808B) hit rate: 66.7%
Table cache: 1 entries (824B) hit rate: 66.7%
Secondary cache: 0 entries (0B) hit rate: 0.0%
Snapshots: 0 earliest seq num: 0
Table iters: 1
Expand Down Expand Up @@ -467,7 +467,7 @@ Zombie tables: 0 (0B)
Backing tables: 0 (0B)
Virtual tables: 0 (0B)
Block cache: 12 entries (2.4KB) hit rate: 24.5%
Table cache: 1 entries (808B) hit rate: 60.0%
Table cache: 1 entries (824B) hit rate: 60.0%
Secondary cache: 0 entries (0B) hit rate: 0.0%
Snapshots: 0 earliest seq num: 0
Table iters: 0
Expand Down Expand Up @@ -528,7 +528,7 @@ Zombie tables: 0 (0B)
Backing tables: 0 (0B)
Virtual tables: 0 (0B)
Block cache: 12 entries (2.4KB) hit rate: 24.5%
Table cache: 1 entries (808B) hit rate: 60.0%
Table cache: 1 entries (824B) hit rate: 60.0%
Secondary cache: 0 entries (0B) hit rate: 0.0%
Snapshots: 0 earliest seq num: 0
Table iters: 0
Expand Down

0 comments on commit 3b862af

Please sign in to comment.