mirror of
https://github.com/prometheus/prometheus.git
synced 2024-12-24 21:24:05 -08:00
Expose NewChainSampleIterator func (#9475)
* expose NewChainSampleIterator func Signed-off-by: Ben Ye <ben.ye@bytedance.com> * add comment Signed-off-by: Ben Ye <ben.ye@bytedance.com> * update comments Signed-off-by: Ben Ye <ben.ye@bytedance.com>
This commit is contained in:
parent
e261eccb35
commit
fdbc40a9ef
|
@ -431,7 +431,7 @@ func ChainedSeriesMerge(series ...Series) Series {
|
|||
for _, s := range series {
|
||||
iterators = append(iterators, s.Iterator())
|
||||
}
|
||||
return newChainSampleIterator(iterators)
|
||||
return NewChainSampleIterator(iterators)
|
||||
},
|
||||
}
|
||||
}
|
||||
|
@ -447,7 +447,10 @@ type chainSampleIterator struct {
|
|||
lastt int64
|
||||
}
|
||||
|
||||
func newChainSampleIterator(iterators []chunkenc.Iterator) chunkenc.Iterator {
|
||||
// NewChainSampleIterator returns a single iterator that iterates over the samples from the given iterators in a sorted
|
||||
// fashion. If samples overlap, one sample from overlapped ones is kept (randomly) and all others with the same
|
||||
// timestamp are dropped.
|
||||
func NewChainSampleIterator(iterators []chunkenc.Iterator) chunkenc.Iterator {
|
||||
return &chainSampleIterator{
|
||||
iterators: iterators,
|
||||
h: nil,
|
||||
|
|
|
@ -631,7 +631,7 @@ func TestChainSampleIterator(t *testing.T) {
|
|||
expected: []tsdbutil.Sample{sample{0, 0}, sample{1, 1}, sample{2, 2}, sample{3, 3}},
|
||||
},
|
||||
} {
|
||||
merged := newChainSampleIterator(tc.input)
|
||||
merged := NewChainSampleIterator(tc.input)
|
||||
actual, err := ExpandSamples(merged, nil)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, tc.expected, actual)
|
||||
|
@ -677,7 +677,7 @@ func TestChainSampleIteratorSeek(t *testing.T) {
|
|||
expected: []tsdbutil.Sample{sample{0, 0}, sample{1, 1}, sample{2, 2}, sample{3, 3}},
|
||||
},
|
||||
} {
|
||||
merged := newChainSampleIterator(tc.input)
|
||||
merged := NewChainSampleIterator(tc.input)
|
||||
actual := []tsdbutil.Sample{}
|
||||
if merged.Seek(tc.seek) {
|
||||
t, v := merged.At()
|
||||
|
|
Loading…
Reference in a new issue