This commit is contained in:
Aliaksandr Valialkin 2024-05-11 00:58:36 +02:00
parent 4c457cf20f
commit fb2a280077
No known key found for this signature in database
GPG key ID: 52C003EE2BCDB9EB
3 changed files with 6 additions and 4 deletions

View file

@ -226,7 +226,7 @@ func (b *block) assertValid() {
//
// It is expected that timestamps are sorted.
//
// b is valid until timestamps and rows are changed.
// b is valid until rows are changed.
func (b *block) MustInitFromRows(timestamps []int64, rows [][]Field) {
b.reset()

View file

@ -116,6 +116,7 @@ func (bd *blockData) mustWriteTo(bh *blockHeader, sw *streamWriters) {
a := getArena()
csh := getColumnsHeader()
chs := csh.resizeColumnHeaders(len(cds))
for i := range cds {
cds[i].mustWriteTo(a, &chs[i], sw)
@ -124,6 +125,7 @@ func (bd *blockData) mustWriteTo(bh *blockHeader, sw *streamWriters) {
bb := longTermBufPool.Get()
bb.B = csh.marshal(bb.B)
putColumnsHeader(csh)
putArena(a)

View file

@ -169,11 +169,11 @@ func TestBlockMustInitFromRowsFullBlock(t *testing.T) {
b := getBlock()
defer putBlock(b)
b.MustInitFromRows(timestamps, rows)
b.assertValid()
if n := b.Len(); n != len(rows) {
t.Fatalf("unexpected total log entries; got %d; want %d", n, len(rows))
}
if b.uncompressedSizeBytes() < maxUncompressedBlockSize {
t.Fatalf("expecting full block")
if n := b.uncompressedSizeBytes(); n < maxUncompressedBlockSize {
t.Fatalf("expecting full block with %d bytes; got %d bytes", maxUncompressedBlockSize, n)
}
b.assertValid()
}