From deb615fff62c3ca0301e229e2fb0c50fb99ae32f Mon Sep 17 00:00:00 2001 From: Ben Ye Date: Sat, 23 Mar 2024 02:05:27 -0700 Subject: [PATCH] expose NewPromSeriesSet (#7214) Signed-off-by: Ben Ye --- pkg/query/iter.go | 11 +++++++++++ pkg/query/querier.go | 28 ++++++++++++++-------------- 2 files changed, 25 insertions(+), 14 deletions(-) diff --git a/pkg/query/iter.go b/pkg/query/iter.go index d55027df69..7bee002df2 100644 --- a/pkg/query/iter.go +++ b/pkg/query/iter.go @@ -27,6 +27,17 @@ type promSeriesSet struct { warns annotations.Annotations } +// NewPromSeriesSet constructs a promSeriesSet. +func NewPromSeriesSet(seriesSet storepb.SeriesSet, mint, maxt int64, aggrs []storepb.Aggr, warns annotations.Annotations) storage.SeriesSet { + return &promSeriesSet{ + set: seriesSet, + mint: mint, + maxt: maxt, + aggrs: aggrs, + warns: warns, + } +} + func (s *promSeriesSet) Next() bool { return s.set.Next() } diff --git a/pkg/query/querier.go b/pkg/query/querier.go index 0cfcc2ad21..d55285b459 100644 --- a/pkg/query/querier.go +++ b/pkg/query/querier.go @@ -364,25 +364,25 @@ func (q *querier) selectFn(ctx context.Context, hints *storage.SelectHints, ms . warns := annotations.New().Merge(resp.warnings) if !q.isDedupEnabled() { - return &promSeriesSet{ - mint: q.mint, - maxt: q.maxt, - set: newStoreSeriesSet(resp.seriesSet), - aggrs: aggrs, - warns: warns, - }, resp.seriesSetStats, nil + return NewPromSeriesSet( + newStoreSeriesSet(resp.seriesSet), + q.mint, + q.maxt, + aggrs, + warns, + ), resp.seriesSetStats, nil } // TODO(bwplotka): Move to deduplication on chunk level inside promSeriesSet, similar to what we have in dedup.NewDedupChunkMerger(). // This however require big refactor, caring about correct AggrChunk to iterator conversion and counter reset apply. // For now we apply simple logic that splits potential overlapping chunks into separate replica series, so we can split the work. - set := &promSeriesSet{ - mint: q.mint, - maxt: q.maxt, - set: dedup.NewOverlapSplit(newStoreSeriesSet(resp.seriesSet)), - aggrs: aggrs, - warns: warns, - } + set := NewPromSeriesSet( + dedup.NewOverlapSplit(newStoreSeriesSet(resp.seriesSet)), + q.mint, + q.maxt, + aggrs, + warns, + ) return dedup.NewSeriesSet(set, hints.Func), resp.seriesSetStats, nil }