From fb2a28007776e337df4fbc76808b3a90e69e7850 Mon Sep 17 00:00:00 2001 From: Aliaksandr Valialkin Date: Sat, 11 May 2024 00:58:36 +0200 Subject: [PATCH] wip --- lib/logstorage/block.go | 2 +- lib/logstorage/block_data.go | 2 ++ lib/logstorage/block_test.go | 6 +++--- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/logstorage/block.go b/lib/logstorage/block.go index 3c14ecb31..9060d9e94 100644 --- a/lib/logstorage/block.go +++ b/lib/logstorage/block.go @@ -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() diff --git a/lib/logstorage/block_data.go b/lib/logstorage/block_data.go index 43f296fb2..436e447f4 100644 --- a/lib/logstorage/block_data.go +++ b/lib/logstorage/block_data.go @@ -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) diff --git a/lib/logstorage/block_test.go b/lib/logstorage/block_test.go index b68b7ea41..13efcf4a8 100644 --- a/lib/logstorage/block_test.go +++ b/lib/logstorage/block_test.go @@ -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() }