@@ -56,7 +56,6 @@ type RawRowWriter struct {
56
56
isStrictObsolete bool
57
57
writingToLowestLevel bool
58
58
restartInterval int
59
- checksumType block.ChecksumType
60
59
// disableKeyOrderChecks disables the checks that keys are added to an
61
60
// sstable in order. It is intended for internal use only in the construction
62
61
// of invalid sstables for testing. See tool/make_test_sstables.go.
@@ -411,8 +410,7 @@ type blockBuf struct {
411
410
// compression is not used) for storing a copy of the data. It is re-used over
412
411
// the lifetime of the blockBuf, avoiding the allocation of a temporary buffer
413
412
// for each block.
414
- dataBuf []byte
415
- checksummer block.Checksummer
413
+ dataBuf []byte
416
414
}
417
415
418
416
func (b * blockBuf ) clear () {
@@ -477,19 +475,20 @@ var dataBlockBufPool = sync.Pool{
477
475
},
478
476
}
479
477
480
- func newDataBlockBuf (restartInterval int , checksumType block. ChecksumType ) * dataBlockBuf {
478
+ func newDataBlockBuf (restartInterval int ) * dataBlockBuf {
481
479
d := dataBlockBufPool .Get ().(* dataBlockBuf )
482
480
d .dataBlock .RestartInterval = restartInterval
483
- d .checksummer .Type = checksumType
484
481
return d
485
482
}
486
483
487
484
func (d * dataBlockBuf ) finish () {
488
485
d .uncompressed = d .dataBlock .Finish ()
489
486
}
490
487
491
- func (d * dataBlockBuf ) compressAndChecksum (compressor * block.Compressor ) {
492
- d .physical = block .CompressAndChecksum (& d .dataBuf , d .uncompressed , blockkind .SSTableData , compressor , & d .checksummer )
488
+ func (d * dataBlockBuf ) compressAndChecksum (
489
+ compressor * block.Compressor , checksummer * block.Checksummer ,
490
+ ) {
491
+ d .physical = block .CompressAndChecksum (& d .dataBuf , d .uncompressed , blockkind .SSTableData , compressor , checksummer )
493
492
}
494
493
495
494
func (d * dataBlockBuf ) shouldFlush (
@@ -994,7 +993,7 @@ func (w *RawRowWriter) flush(key InternalKey) error {
994
993
}
995
994
w .dataBlockBuf .finish ()
996
995
w .maybeIncrementTombstoneDenseBlocks ()
997
- w .dataBlockBuf .compressAndChecksum (& w .layout .compressor )
996
+ w .dataBlockBuf .compressAndChecksum (& w .layout .compressor , & w . layout . checksummer )
998
997
// Since dataBlockEstimates.addInflightDataBlock was never called, the
999
998
// inflightSize is set to 0.
1000
999
w .coordination .sizeEstimate .dataBlockCompressed (w .dataBlockBuf .physical .LengthWithoutTrailer (), 0 )
@@ -1053,7 +1052,7 @@ func (w *RawRowWriter) flush(key InternalKey) error {
1053
1052
1054
1053
w .dataBlockBuf = nil
1055
1054
err = w .coordination .writeQueue .addSync (writeTask )
1056
- w .dataBlockBuf = newDataBlockBuf (w .restartInterval , w . checksumType )
1055
+ w .dataBlockBuf = newDataBlockBuf (w .restartInterval )
1057
1056
1058
1057
return err
1059
1058
}
@@ -1679,7 +1678,6 @@ func newRowWriter(writable objstorage.Writable, o WriterOptions) *RawRowWriter {
1679
1678
}
1680
1679
o = o .ensureDefaults ()
1681
1680
w := & RawRowWriter {
1682
- layout : makeLayoutWriter (writable , o ),
1683
1681
meta : WriterMetadata {
1684
1682
SmallestSeqNum : math .MaxUint64 ,
1685
1683
},
@@ -1694,7 +1692,6 @@ func newRowWriter(writable objstorage.Writable, o WriterOptions) *RawRowWriter {
1694
1692
isStrictObsolete : o .IsStrictObsolete ,
1695
1693
writingToLowestLevel : o .WritingToLowestLevel ,
1696
1694
restartInterval : o .BlockRestartInterval ,
1697
- checksumType : o .Checksum ,
1698
1695
disableKeyOrderChecks : o .internal .DisableKeyOrderChecks ,
1699
1696
indexBlock : newIndexBlockBuf (),
1700
1697
rangeDelBlock : rowblk.Writer {RestartInterval : 1 },
@@ -1704,25 +1701,22 @@ func newRowWriter(writable objstorage.Writable, o WriterOptions) *RawRowWriter {
1704
1701
numDeletionsThreshold : o .NumDeletionsThreshold ,
1705
1702
deletionSizeRatioThreshold : o .DeletionSizeRatioThreshold ,
1706
1703
}
1704
+ w .layout .Init (writable , o )
1707
1705
w .dataFlush = block .MakeFlushGovernor (o .BlockSize , o .BlockSizeThreshold , o .SizeClassAwareThreshold , o .AllocatorSizeClasses )
1708
1706
w .indexFlush = block .MakeFlushGovernor (o .IndexBlockSize , o .BlockSizeThreshold , o .SizeClassAwareThreshold , o .AllocatorSizeClasses )
1709
1707
if w .tableFormat >= TableFormatPebblev3 {
1710
1708
w .shortAttributeExtractor = o .ShortAttributeExtractor
1711
1709
if ! o .DisableValueBlocks {
1712
1710
w .valueBlockWriter = valblk .NewWriter (
1713
1711
block .MakeFlushGovernor (o .BlockSize , o .BlockSizeThreshold , o .SizeClassAwareThreshold , o .AllocatorSizeClasses ),
1714
- & w .layout .compressor , w . checksumType , func (compressedSize int ) {
1712
+ & w .layout .compressor , & w . layout . checksummer , func (compressedSize int ) {
1715
1713
w .coordination .sizeEstimate .dataBlockCompressed (compressedSize , 0 )
1716
1714
},
1717
1715
)
1718
1716
}
1719
1717
}
1720
1718
1721
- w .dataBlockBuf = newDataBlockBuf (w .restartInterval , w .checksumType )
1722
-
1723
- w .blockBuf = blockBuf {
1724
- checksummer : block.Checksummer {Type : o .Checksum },
1725
- }
1719
+ w .dataBlockBuf = newDataBlockBuf (w .restartInterval )
1726
1720
1727
1721
w .coordination .init (w )
1728
1722
defer func () {
@@ -1929,7 +1923,7 @@ func (w *RawRowWriter) copyDataBlocks(
1929
1923
func (w * RawRowWriter ) addDataBlock (b , sep []byte , bhp block.HandleWithProperties ) error {
1930
1924
blockBuf := & w .dataBlockBuf .blockBuf
1931
1925
pb := block .CompressAndChecksum (
1932
- & blockBuf .dataBuf , b , blockkind .SSTableData , & w .layout .compressor , & blockBuf .checksummer ,
1926
+ & blockBuf .dataBuf , b , blockkind .SSTableData , & w .layout .compressor , & w . layout .checksummer ,
1933
1927
)
1934
1928
1935
1929
// layout.WriteDataBlock keeps layout.offset up-to-date for us.
0 commit comments