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 d6ce934 commit f1b98ed
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 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

0 comments on commit f1b98ed

Please sign in to comment.