Skip to content

Commit

Permalink
colblk: more reader->decoder renames
Browse files Browse the repository at this point in the history
  • Loading branch information
RaduBerinde committed Oct 11, 2024
1 parent 0501caf commit 4b62ea0
Show file tree
Hide file tree
Showing 6 changed files with 118 additions and 118 deletions.
18 changes: 9 additions & 9 deletions sstable/colblk/block.go
Original file line number Diff line number Diff line change
Expand Up @@ -281,16 +281,16 @@ func FinishBlock(rows int, writers []ColumnWriter) []byte {
// DecodeColumn decodes the col'th column of the provided reader's block as a
// column of dataType using decodeFunc.
func DecodeColumn[V any](
r *BlockDecoder, col int, rows int, dataType DataType, decodeFunc DecodeFunc[V],
d *BlockDecoder, col int, rows int, dataType DataType, decodeFunc DecodeFunc[V],
) V {
if uint16(col) >= r.header.Columns {
panic(errors.AssertionFailedf("column %d is out of range [0, %d)", col, r.header.Columns))
if uint16(col) >= d.header.Columns {
panic(errors.AssertionFailedf("column %d is out of range [0, %d)", col, d.header.Columns))
}
if dt := r.dataType(col); dt != dataType {
if dt := d.dataType(col); dt != dataType {
panic(errors.AssertionFailedf("column %d is type %s; not %s", col, dt, dataType))
}
v, endOffset := decodeFunc(r.data, r.pageStart(col), rows)
if nextColumnOff := r.pageStart(col + 1); endOffset != nextColumnOff {
v, endOffset := decodeFunc(d.data, d.pageStart(col), rows)
if nextColumnOff := d.pageStart(col + 1); endOffset != nextColumnOff {
panic(errors.AssertionFailedf("column %d decoded to offset %d; expected %d", col, endOffset, nextColumnOff))
}
return v
Expand All @@ -307,9 +307,9 @@ type BlockDecoder struct {
// new BlockDecoder configured to read from the block. The caller must ensure
// that the data is formatted as to the block layout specification.
func DecodeBlock(data []byte, customHeaderSize uint32) BlockDecoder {
r := BlockDecoder{}
r.Init(data, customHeaderSize)
return r
d := BlockDecoder{}
d.Init(data, customHeaderSize)
return d
}

// Init initializes a BlockDecoder with the data contained in the provided block.
Expand Down
20 changes: 10 additions & 10 deletions sstable/colblk/cockroach_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,11 +194,11 @@ var _ KeySeeker = (*cockroachKeySeeker)(nil)

// Init is part of the KeySeeker interface.
func (ks *cockroachKeySeeker) Init(d *DataBlockDecoder) error {
ks.roachKeys = d.r.PrefixBytes(cockroachColRoachKey)
ks.roachKeys = d.d.PrefixBytes(cockroachColRoachKey)
ks.roachKeyChanged = d.prefixChanged
ks.mvccWallTimes = d.r.Uints(cockroachColMVCCWallTime)
ks.mvccLogical = d.r.Uints(cockroachColMVCCLogical)
ks.untypedVersions = d.r.RawBytes(cockroachColUntypedVersion)
ks.mvccWallTimes = d.d.Uints(cockroachColMVCCWallTime)
ks.mvccLogical = d.d.Uints(cockroachColMVCCLogical)
ks.untypedVersions = d.d.RawBytes(cockroachColUntypedVersion)
return nil
}

Expand Down Expand Up @@ -408,13 +408,13 @@ func TestCockroachDataBlock(t *testing.T) {
BaseWallTime: seed,
}, valueLen)

var reader DataBlockDecoder
var decoder DataBlockDecoder
var it DataBlockIter
it.InitOnce(cockroachKeySchema, crdbtest.Compare, crdbtest.Split, getLazyValuer(func([]byte) base.LazyValue {
return base.LazyValue{ValueOrHandle: []byte("mock external value")}
}))
reader.Init(cockroachKeySchema, serializedBlock)
if err := it.Init(&reader, block.IterTransforms{}); err != nil {
decoder.Init(cockroachKeySchema, serializedBlock)
if err := it.Init(&decoder, block.IterTransforms{}); err != nil {
t.Fatal(err)
}

Expand Down Expand Up @@ -634,13 +634,13 @@ func benchmarkCockroachDataBlockIter(

serializedBlock, keys, _ := generateDataBlock(rng, targetBlockSize, cfg.KeyConfig, cfg.ValueLen)

var reader DataBlockDecoder
var decoder DataBlockDecoder
var it DataBlockIter
it.InitOnce(cockroachKeySchema, crdbtest.Compare, crdbtest.Split, getLazyValuer(func([]byte) base.LazyValue {
return base.LazyValue{ValueOrHandle: []byte("mock external value")}
}))
reader.Init(cockroachKeySchema, serializedBlock)
if err := it.Init(&reader, transforms); err != nil {
decoder.Init(cockroachKeySchema, serializedBlock)
if err := it.Init(&decoder, transforms); err != nil {
b.Fatal(err)
}
avgRowSize := float64(len(serializedBlock)) / float64(len(keys))
Expand Down
Loading

0 comments on commit 4b62ea0

Please sign in to comment.