Skip to content

Commit 4d91c2c

Browse files
committed
sstable/colblk: remove BlockDecoder from DataBlockDecoder
Fixes: #5157
1 parent 26928ef commit 4d91c2c

File tree

7 files changed

+25
-27
lines changed

7 files changed

+25
-27
lines changed

sstable/block/block.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ func CastMetadata[T any](md *Metadata) *T {
243243

244244
// MetadataSize is the size of the metadata. The value is chosen to fit a
245245
// colblk.DataBlockDecoder and a CockroachDB colblk.KeySeeker.
246-
const MetadataSize = 312
246+
const MetadataSize = 280
247247

248248
// Assert that MetadataSize is a multiple of 8. This is necessary to keep the
249249
// block data buffer aligned.

sstable/block/testdata/flush_governor

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ should not flush
2929
init target-block-size=800 size-class-aware-threshold=60 size-classes=(820, 1020, 1320, 1820)
3030
----
3131
low watermark: 480
32-
high watermark: 976
33-
targetBoundary: 676
32+
high watermark: 1008
33+
targetBoundary: 708
3434

3535
# Should not flush when the "after" block fits in the same size class.
3636
should-flush size-before=600 size-after=650
@@ -82,8 +82,8 @@ targetBoundary: 1000
8282
init target-block-size=32768 jemalloc-size-classes
8383
----
8484
low watermark: 19661
85-
high watermark: 40616
86-
targetBoundary: 32424
85+
high watermark: 40648
86+
targetBoundary: 32456
8787

8888
# We should not flush until exceeding the boundary.
8989
should-flush size-before=30000 size-after=31000

sstable/colblk/data_block.go

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -792,7 +792,8 @@ func (rw *DataBlockRewriter) RewriteSuffixes(
792792
}
793793

794794
type blockDecoderAndKeySeekerMetadata struct {
795-
d DataBlockDecoder
795+
d DataBlockDecoder
796+
headerRows int
796797
// Pad to ensure KeySeekerMetadata is 8-byte aligned.
797798
_ [(8 - unsafe.Sizeof(DataBlockDecoder{})%8) % 8]byte
798799
keySchemaMeta KeySeekerMetadata
@@ -815,6 +816,7 @@ func InitDataBlockMetadata(schema *KeySchema, md *block.Metadata, data []byte) (
815816
}
816817
}()
817818
bd := metadatas.d.Init(schema, data)
819+
metadatas.headerRows = int(bd.header.Rows)
818820
schema.InitKeySeekerMetadata(&metadatas.keySchemaMeta, &metadatas.d, bd)
819821
return nil
820822
}
@@ -856,7 +858,6 @@ func InitKeyspanBlockMetadata(md *block.Metadata, data []byte) (err error) {
856858
// A DataBlockDecoder holds state for interpreting a columnar data block. It may
857859
// be shared among multiple DataBlockIters.
858860
type DataBlockDecoder struct {
859-
d BlockDecoder
860861
// trailers holds an array of the InternalKey trailers, encoding the key
861862
// kind and sequence number of each key.
862863
trailers UnsafeUints
@@ -897,7 +898,6 @@ func (d *DataBlockDecoder) Init(schema *KeySchema, data []byte) *BlockDecoder {
897898
}
898899
bd := BlockDecoder{}
899900
bd.Init(data, DataBlockCustomHeaderSize+schema.HeaderSize)
900-
d.d = bd
901901
d.trailers = bd.Uints(len(schema.ColumnTypes) + dataBlockColumnTrailer)
902902
d.prefixChanged = bd.Bitmap(len(schema.ColumnTypes) + dataBlockColumnPrefixChanged)
903903
d.values = bd.RawBytes(len(schema.ColumnTypes) + dataBlockColumnValue)
@@ -1093,11 +1093,9 @@ func (i *DataBlockIter) InitHandle(
10931093
i.h.Release()
10941094
i.h = h
10951095

1096-
numRows := int(i.d.d.header.Rows)
1097-
i.maxRow = numRows - 1
1098-
1096+
i.maxRow = blockMeta.headerRows - 1
10991097
i.transforms = transforms
1100-
if i.transforms.HideObsoletePoints && i.d.isObsolete.SeekSetBitGE(0) == numRows {
1098+
if i.transforms.HideObsoletePoints && i.d.isObsolete.SeekSetBitGE(0) == blockMeta.headerRows {
11011099
// There are no obsolete points in the block; don't bother checking.
11021100
i.transforms.HideObsoletePoints = false
11031101
}

testdata/compaction/value_separation

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ ITERATORS
158158
block cache | file cache | filter | sst iters | snapshots
159159
entries | hit rate | entries | hit rate | util | open | open
160160
-------------+-------------+--------------+-------------+--------------+-------------+------------
161-
5 (1.8KB) | 81.8% | 1 (392B) | 89.2% | 0.0% | 0 | 0
161+
5 (1.6KB) | 81.8% | 1 (392B) | 89.2% | 0.0% | 0 | 0
162162

163163
FILES tables | blob files | blob values
164164
stats prog | backing | zombie | live | zombie | total | refed
@@ -433,7 +433,7 @@ ITERATORS
433433
block cache | file cache | filter | sst iters | snapshots
434434
entries | hit rate | entries | hit rate | util | open | open
435435
-------------+-------------+--------------+-------------+--------------+-------------+------------
436-
7 (2.5KB) | 59.6% | 1 (504B) | 78.6% | 0.0% | 0 | 0
436+
7 (2.3KB) | 59.6% | 1 (504B) | 78.6% | 0.0% | 0 | 0
437437

438438
FILES tables | blob files | blob values
439439
stats prog | backing | zombie | live | zombie | total | refed

testdata/event_listener

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ ITERATORS
285285
block cache | file cache | filter | sst iters | snapshots
286286
entries | hit rate | entries | hit rate | util | open | open
287287
-------------+-------------+--------------+-------------+--------------+-------------+------------
288-
2 (736B) | 0.0% | 0 (0B) | 50.0% | 0.0% | 0 | 0
288+
2 (672B) | 0.0% | 0 (0B) | 50.0% | 0.0% | 0 | 0
289289

290290
FILES tables | blob files | blob values
291291
stats prog | backing | zombie | live | zombie | total | refed
@@ -425,7 +425,7 @@ ITERATORS
425425
block cache | file cache | filter | sst iters | snapshots
426426
entries | hit rate | entries | hit rate | util | open | open
427427
-------------+-------------+--------------+-------------+--------------+-------------+------------
428-
6 (2.2KB) | 0.0% | 0 (0B) | 50.0% | 0.0% | 0 | 0
428+
6 (2KB) | 0.0% | 0 (0B) | 50.0% | 0.0% | 0 | 0
429429

430430
FILES tables | blob files | blob values
431431
stats prog | backing | zombie | live | zombie | total | refed

testdata/ingest

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ ITERATORS
6969
block cache | file cache | filter | sst iters | snapshots
7070
entries | hit rate | entries | hit rate | util | open | open
7171
-------------+-------------+--------------+-------------+--------------+-------------+------------
72-
3 (1KB) | 15.4% | 1 (280B) | 50.0% | 0.0% | 0 | 0
72+
3 (924B) | 15.4% | 1 (280B) | 50.0% | 0.0% | 0 | 0
7373

7474
FILES tables | blob files | blob values
7575
stats prog | backing | zombie | live | zombie | total | refed

testdata/metrics

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ ITERATORS
127127
block cache | file cache | filter | sst iters | snapshots
128128
entries | hit rate | entries | hit rate | util | open | open
129129
-------------+-------------+--------------+-------------+--------------+-------------+------------
130-
2 (747B) | 0.0% | 1 (280B) | 0.0% | 0.0% | 1 | 0
130+
2 (683B) | 0.0% | 1 (280B) | 0.0% | 0.0% | 1 | 0
131131

132132
FILES tables | blob files | blob values
133133
stats prog | backing | zombie | live | zombie | total | refed
@@ -228,7 +228,7 @@ ITERATORS
228228
block cache | file cache | filter | sst iters | snapshots
229229
entries | hit rate | entries | hit rate | util | open | open
230230
-------------+-------------+--------------+-------------+--------------+-------------+------------
231-
2 (747B) | 33.3% | 2 (560B) | 66.7% | 0.0% | 2 | 0
231+
2 (683B) | 33.3% | 2 (560B) | 66.7% | 0.0% | 2 | 0
232232

233233
FILES tables | blob files | blob values
234234
stats prog | backing | zombie | live | zombie | total | refed
@@ -312,7 +312,7 @@ ITERATORS
312312
block cache | file cache | filter | sst iters | snapshots
313313
entries | hit rate | entries | hit rate | util | open | open
314314
-------------+-------------+--------------+-------------+--------------+-------------+------------
315-
2 (747B) | 33.3% | 2 (560B) | 66.7% | 0.0% | 2 | 0
315+
2 (683B) | 33.3% | 2 (560B) | 66.7% | 0.0% | 2 | 0
316316

317317
FILES tables | blob files | blob values
318318
stats prog | backing | zombie | live | zombie | total | refed
@@ -393,7 +393,7 @@ ITERATORS
393393
block cache | file cache | filter | sst iters | snapshots
394394
entries | hit rate | entries | hit rate | util | open | open
395395
-------------+-------------+--------------+-------------+--------------+-------------+------------
396-
2 (747B) | 33.3% | 1 (280B) | 66.7% | 0.0% | 1 | 0
396+
2 (683B) | 33.3% | 1 (280B) | 66.7% | 0.0% | 1 | 0
397397

398398
FILES tables | blob files | blob values
399399
stats prog | backing | zombie | live | zombie | total | refed
@@ -867,7 +867,7 @@ ITERATORS
867867
block cache | file cache | filter | sst iters | snapshots
868868
entries | hit rate | entries | hit rate | util | open | open
869869
-------------+-------------+--------------+-------------+--------------+-------------+------------
870-
6 (2.2KB) | 7.3% | 0 (0B) | 55.0% | 0.0% | 0 | 0
870+
6 (2KB) | 7.3% | 0 (0B) | 55.0% | 0.0% | 0 | 0
871871

872872
FILES tables | blob files | blob values
873873
stats prog | backing | zombie | live | zombie | total | refed
@@ -988,7 +988,7 @@ ITERATORS
988988
block cache | file cache | filter | sst iters | snapshots
989989
entries | hit rate | entries | hit rate | util | open | open
990990
-------------+-------------+--------------+-------------+--------------+-------------+------------
991-
6 (2.2KB) | 7.3% | 0 (0B) | 55.0% | 0.0% | 0 | 0
991+
6 (2KB) | 7.3% | 0 (0B) | 55.0% | 0.0% | 0 | 0
992992

993993
FILES tables | blob files | blob values
994994
stats prog | backing | zombie | live | zombie | total | refed
@@ -1568,7 +1568,7 @@ ITERATORS
15681568
block cache | file cache | filter | sst iters | snapshots
15691569
entries | hit rate | entries | hit rate | util | open | open
15701570
-------------+-------------+--------------+-------------+--------------+-------------+------------
1571-
2 (739B) | 0.0% | 0 (0B) | 50.0% | 0.0% | 0 | 0
1571+
2 (675B) | 0.0% | 0 (0B) | 50.0% | 0.0% | 0 | 0
15721572

15731573
FILES tables | blob files | blob values
15741574
stats prog | backing | zombie | live | zombie | total | refed
@@ -1656,7 +1656,7 @@ ITERATORS
16561656
block cache | file cache | filter | sst iters | snapshots
16571657
entries | hit rate | entries | hit rate | util | open | open
16581658
-------------+-------------+--------------+-------------+--------------+-------------+------------
1659-
2 (739B) | 0.0% | 0 (0B) | 50.0% | 0.0% | 0 | 0
1659+
2 (675B) | 0.0% | 0 (0B) | 50.0% | 0.0% | 0 | 0
16601660

16611661
FILES tables | blob files | blob values
16621662
stats prog | backing | zombie | live | zombie | total | refed
@@ -1931,7 +1931,7 @@ ITERATORS
19311931
block cache | file cache | filter | sst iters | snapshots
19321932
entries | hit rate | entries | hit rate | util | open | open
19331933
-------------+-------------+--------------+-------------+--------------+-------------+------------
1934-
2 (726B) | 0.0% | 2 (560B) | 0.0% | 0.0% | 0 | 0
1934+
2 (662B) | 0.0% | 2 (560B) | 0.0% | 0.0% | 0 | 0
19351935

19361936
FILES tables | blob files | blob values
19371937
stats prog | backing | zombie | live | zombie | total | refed
@@ -2008,7 +2008,7 @@ ITERATORS
20082008
block cache | file cache | filter | sst iters | snapshots
20092009
entries | hit rate | entries | hit rate | util | open | open
20102010
-------------+-------------+--------------+-------------+--------------+-------------+------------
2011-
2 (726B) | 0.0% | 2 (560B) | 0.0% | 0.0% | 0 | 0
2011+
2 (662B) | 0.0% | 2 (560B) | 0.0% | 0.0% | 0 | 0
20122012

20132013
FILES tables | blob files | blob values
20142014
stats prog | backing | zombie | live | zombie | total | refed

0 commit comments

Comments
 (0)