From d95b0972505f61be0b23b4dfedb8b4816392491b Mon Sep 17 00:00:00 2001 From: Ben Ye Date: Wed, 19 May 2021 08:01:35 -0400 Subject: [PATCH] expose seriesToChunkEncoder (#8845) Signed-off-by: yeya24 --- storage/merge.go | 2 +- storage/series.go | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/storage/merge.go b/storage/merge.go index fca052ca1..81e45d55d 100644 --- a/storage/merge.go +++ b/storage/merge.go @@ -667,7 +667,7 @@ func (c *compactChunkIterator) Next() bool { } // Add last as it's not yet included in overlap. We operate on same series, so labels does not matter here. - iter = (&seriesToChunkEncoder{Series: c.mergeFunc(append(overlapping, newChunkToSeriesDecoder(nil, c.curr))...)}).Iterator() + iter = NewSeriesToChunkEncoder(c.mergeFunc(append(overlapping, newChunkToSeriesDecoder(nil, c.curr))...)).Iterator() if !iter.Next() { if c.err = iter.Err(); c.err != nil { return false diff --git a/storage/series.go b/storage/series.go index 5f16d053c..d92b4fd18 100644 --- a/storage/series.go +++ b/storage/series.go @@ -204,9 +204,7 @@ func (c *seriesSetToChunkSet) Next() bool { } func (c *seriesSetToChunkSet) At() ChunkSeries { - return &seriesToChunkEncoder{ - Series: c.SeriesSet.At(), - } + return NewSeriesToChunkEncoder(c.SeriesSet.At()) } func (c *seriesSetToChunkSet) Err() error { @@ -219,6 +217,11 @@ type seriesToChunkEncoder struct { const seriesToChunkEncoderSplit = 120 +// NewSeriesToChunkEncoder encodes samples to chunks with 120 samples limit. +func NewSeriesToChunkEncoder(series Series) ChunkSeries { + return &seriesToChunkEncoder{series} +} + func (s *seriesToChunkEncoder) Iterator() chunks.Iterator { chk := chunkenc.NewXORChunk() app, err := chk.Appender()