From f1b98ed7cfcc16047750d5c81eae4344123a9eac Mon Sep 17 00:00:00 2001 From: David Taylor Date: Tue, 23 Jan 2024 20:16:27 +0000 Subject: [PATCH] sstable: capture elided prefix in a prop --- sstable/properties.go | 7 ++++++- sstable/testdata/writer | 4 +++- sstable/writer.go | 1 + 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/sstable/properties.go b/sstable/properties.go index 3bbf34a8afc..53932d73d2e 100644 --- a/sstable/properties.go +++ b/sstable/properties.go @@ -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. @@ -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} diff --git a/sstable/testdata/writer b/sstable/testdata/writer index 44236a09cba..492f9a9dc45 100644 --- a/sstable/testdata/writer +++ b/sstable/testdata/writer @@ -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 @@ -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_ diff --git a/sstable/writer.go b/sstable/writer.go index 4322b062c26..08d61365f2d 100644 --- a/sstable/writer.go +++ b/sstable/writer.go @@ -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