Skip to content

Commit 1985e8d

Browse files
committed
block: pass compressor as pointer
1 parent 9db6dee commit 1985e8d

File tree

9 files changed

+12
-12
lines changed

9 files changed

+12
-12
lines changed

sstable/blob/blob.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ func (w *FileWriter) flush() {
213213
if w.valuesEncoder.Count() == 0 {
214214
panic(errors.AssertionFailedf("no values to flush"))
215215
}
216-
pb, bh := block.CompressAndChecksumToTempBuffer(w.valuesEncoder.Finish(), w.compressor, &w.checksummer)
216+
pb, bh := block.CompressAndChecksumToTempBuffer(w.valuesEncoder.Finish(), &w.compressor, &w.checksummer)
217217
compressedLen := uint64(pb.LengthWithoutTrailer())
218218
w.stats.BlockCount++
219219
off := w.stats.FileLen

sstable/block/compression.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ func (b *PhysicalBlock) WriteTo(w objstorage.Writable) (n int, err error) {
260260
// the compressed payload is discarded and the original, uncompressed block data
261261
// is used to avoid unnecessary decompression overhead at read time.
262262
func CompressAndChecksum(
263-
dst *[]byte, blockData []byte, compressor Compressor, checksummer *Checksummer,
263+
dst *[]byte, blockData []byte, compressor *Compressor, checksummer *Checksummer,
264264
) PhysicalBlock {
265265
buf := (*dst)[:0]
266266
// Compress the buffer, discarding the result if the improvement isn't at
@@ -284,7 +284,7 @@ func CompressAndChecksum(
284284
// into a TempBuffer. The caller should Release() the TempBuffer once it is no
285285
// longer necessary.
286286
func CompressAndChecksumToTempBuffer(
287-
blockData []byte, compressor Compressor, checksummer *Checksummer,
287+
blockData []byte, compressor *Compressor, checksummer *Checksummer,
288288
) (PhysicalBlock, *TempBuffer) {
289289
// Grab a buffer to use as the destination for compression.
290290
compressedBuf := NewTempBuffer()

sstable/block/compression_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ func TestBufferRandomized(t *testing.T) {
5252
s := b.Data()
5353
require.Equal(t, vbuf, s[len(s)-len(vbuf):])
5454
}
55-
_, bh := CompressAndChecksumToTempBuffer(b.Data(), compressor, &checksummer)
55+
_, bh := CompressAndChecksumToTempBuffer(b.Data(), &compressor, &checksummer)
5656
b.Reset()
5757
bh.Release()
5858
})

sstable/block/compressor.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ func (c *Compressor) Close() {
4040

4141
// NoopCompressor is a Compressor that does not compress data. It does not have
4242
// any state and can be used in parallel.
43-
var NoopCompressor = Compressor{
43+
var NoopCompressor = &Compressor{
4444
algorithm: compression.NoCompression,
4545
compressor: compression.GetCompressor(compression.None),
4646
}

sstable/colblk_writer.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -723,7 +723,7 @@ func (w *RawColumnWriter) enqueueDataBlock(
723723
cb.physical = block.CompressAndChecksum(
724724
&cb.blockBuf.dataBuf,
725725
serializedBlock,
726-
w.compressor,
726+
&w.compressor,
727727
&cb.blockBuf.checksummer,
728728
)
729729
return w.enqueuePhysicalBlock(cb, separator)
@@ -1250,7 +1250,7 @@ func (w *RawColumnWriter) addDataBlock(b, sep []byte, bhp block.HandleWithProper
12501250
cb.physical = block.CompressAndChecksum(
12511251
&cb.blockBuf.dataBuf,
12521252
b,
1253-
w.compressor,
1253+
&w.compressor,
12541254
&cb.blockBuf.checksummer,
12551255
)
12561256
if err := w.enqueuePhysicalBlock(cb, sep); err != nil {

sstable/layout.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -920,7 +920,7 @@ func (w *layoutWriter) writeBlock(
920920
// TODO(radu): store a compressor in the layoutWriter.
921921
compressor := block.MakeCompressor(compression)
922922
defer compressor.Close()
923-
pb := block.CompressAndChecksum(&buf.dataBuf, b, compressor, &buf.checksummer)
923+
pb := block.CompressAndChecksum(&buf.dataBuf, b, &compressor, &buf.checksummer)
924924
h, err := w.writePrecompressedBlock(pb)
925925
return h, err
926926
}

sstable/rowblk_writer.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -492,7 +492,7 @@ func (d *dataBlockBuf) compressAndChecksum(c block.Compression) {
492492
// TODO(radu): pass a Compressor here.
493493
compressor := block.MakeCompressor(c)
494494
defer compressor.Close()
495-
d.physical = block.CompressAndChecksum(&d.dataBuf, d.uncompressed, compressor, &d.checksummer)
495+
d.physical = block.CompressAndChecksum(&d.dataBuf, d.uncompressed, &compressor, &d.checksummer)
496496
}
497497

498498
func (d *dataBlockBuf) shouldFlush(
@@ -1938,7 +1938,7 @@ func (w *RawRowWriter) addDataBlock(b, sep []byte, bhp block.HandleWithPropertie
19381938
pb := block.CompressAndChecksum(
19391939
&blockBuf.dataBuf,
19401940
b,
1941-
compressor,
1941+
&compressor,
19421942
&blockBuf.checksummer,
19431943
)
19441944

sstable/suffix_rewriter.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ func rewriteDataBlocksInParallel(
192192
return err
193193
}
194194
compressedBuf = compressedBuf[:cap(compressedBuf)]
195-
finished := block.CompressAndChecksum(&compressedBuf, outputBlock, compressor, &checksummer)
195+
finished := block.CompressAndChecksum(&compressedBuf, outputBlock, &compressor, &checksummer)
196196
output[i].physical = finished.CloneWithByteAlloc(&blockAlloc)
197197
}
198198
return nil

sstable/valblk/writer.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ func (w *Writer) Size() uint64 {
9191
}
9292

9393
func (w *Writer) compressAndFlush() {
94-
physicalBlock, bufHandle := block.CompressAndChecksumToTempBuffer(w.buf.Data(), w.compressor, &w.checksummer)
94+
physicalBlock, bufHandle := block.CompressAndChecksumToTempBuffer(w.buf.Data(), &w.compressor, &w.checksummer)
9595
w.buf.Reset()
9696
bh := block.Handle{Offset: w.totalBlockBytes, Length: uint64(physicalBlock.LengthWithoutTrailer())}
9797
w.totalBlockBytes += uint64(physicalBlock.LengthWithTrailer())

0 commit comments

Comments
 (0)