From 9e8e4cca6ad258ee3c70acb219fc5959b14e92a6 Mon Sep 17 00:00:00 2001 From: Aliaksandr Valialkin Date: Tue, 6 Feb 2024 22:43:45 +0200 Subject: [PATCH] lib/storage: move fixupTimestamps() call to Block.Init() This is a follow-up for 0bf7921721eda87621009a86fb9e19c8ee5485fe --- lib/storage/block.go | 3 +++ lib/storage/raw_row.go | 2 -- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/storage/block.go b/lib/storage/block.go index 6513c4c44..1a3d1f06d 100644 --- a/lib/storage/block.go +++ b/lib/storage/block.go @@ -95,6 +95,9 @@ func (b *Block) Init(tsid *TSID, timestamps, values []int64, scale int16, precis b.bh.PrecisionBits = precisionBits b.timestamps = append(b.timestamps[:0], timestamps...) b.values = append(b.values[:0], values...) + if len(b.timestamps) > 0 { + b.fixupTimestamps() + } } // nextRow advances to the next row. diff --git a/lib/storage/raw_row.go b/lib/storage/raw_row.go index 549774b19..0f267da03 100644 --- a/lib/storage/raw_row.go +++ b/lib/storage/raw_row.go @@ -118,7 +118,6 @@ func (rrm *rawRowsMarshaler) marshalToInmemoryPart(mp *inmemoryPart, rows []rawR rrm.auxValues, scale = decimal.AppendFloatToDecimal(rrm.auxValues[:0], rrm.auxFloatValues) tmpBlock.Init(tsid, rrm.auxTimestamps, rrm.auxValues, scale, precisionBits) - tmpBlock.fixupTimestamps() rrm.bsw.WriteExternalBlock(tmpBlock, ph, &rowsMerged) tsid = &r.TSID @@ -129,7 +128,6 @@ func (rrm *rawRowsMarshaler) marshalToInmemoryPart(mp *inmemoryPart, rows []rawR rrm.auxValues, scale = decimal.AppendFloatToDecimal(rrm.auxValues[:0], rrm.auxFloatValues) tmpBlock.Init(tsid, rrm.auxTimestamps, rrm.auxValues, scale, precisionBits) - tmpBlock.fixupTimestamps() rrm.bsw.WriteExternalBlock(tmpBlock, ph, &rowsMerged) if rowsMerged != uint64(len(rows)) { logger.Panicf("BUG: unexpected rowsMerged; got %d; want %d", rowsMerged, len(rows))