mirror of
https://github.com/prometheus/prometheus.git
synced 2025-03-05 20:59:13 -08:00
Move to histogram.Histogram pointers
This is to avoid copying the many fields of a histogram.Histogram all the time. This also fixes a bunch of formerly broken tests. Signed-off-by: beorn7 <beorn@grafana.com>
This commit is contained in:
parent
f1065e44a4
commit
4c28d9fac7
|
@ -1190,7 +1190,7 @@ func (n notReadyAppender) AppendExemplar(ref uint64, l labels.Labels, e exemplar
|
||||||
return 0, tsdb.ErrNotReady
|
return 0, tsdb.ErrNotReady
|
||||||
}
|
}
|
||||||
|
|
||||||
func (n notReadyAppender) AppendHistogram(ref uint64, l labels.Labels, t int64, sh histogram.Histogram) (uint64, error) {
|
func (n notReadyAppender) AppendHistogram(ref uint64, l labels.Labels, t int64, h *histogram.Histogram) (uint64, error) {
|
||||||
return 0, tsdb.ErrNotReady
|
return 0, tsdb.ErrNotReady
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -460,7 +460,7 @@ func query(ctx context.Context, qs string, t time.Time, engine *promql.Engine, q
|
||||||
return v, nil
|
return v, nil
|
||||||
case promql.Scalar:
|
case promql.Scalar:
|
||||||
return promql.Vector{promql.Sample{
|
return promql.Vector{promql.Sample{
|
||||||
Point: promql.Point(v),
|
Point: promql.Point{T: v.T, V: v.V},
|
||||||
Metric: labels.Labels{},
|
Metric: labels.Labels{},
|
||||||
}}, nil
|
}}, nil
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -30,7 +30,7 @@ type Parser interface {
|
||||||
|
|
||||||
// Histogram returns the bytes of a series with a sparse histogram as a
|
// Histogram returns the bytes of a series with a sparse histogram as a
|
||||||
// value, the timestamp if set, and the histogram in the current sample.
|
// value, the timestamp if set, and the histogram in the current sample.
|
||||||
Histogram() ([]byte, *int64, histogram.Histogram)
|
Histogram() ([]byte, *int64, *histogram.Histogram)
|
||||||
|
|
||||||
// Help returns the metric name and help text in the current entry.
|
// Help returns the metric name and help text in the current entry.
|
||||||
// Must only be called after Next returned a help entry.
|
// Must only be called after Next returned a help entry.
|
||||||
|
|
|
@ -114,10 +114,10 @@ func (p *OpenMetricsParser) Series() ([]byte, *int64, float64) {
|
||||||
return p.series, nil, p.val
|
return p.series, nil, p.val
|
||||||
}
|
}
|
||||||
|
|
||||||
// Histogram always returns (nil, nil, histogram.Histogram{}) because
|
// Histogram always returns (nil, nil, nil) because OpenMetrics does not support
|
||||||
// OpenMetrics does not support sparse histograms.
|
// sparse histograms.
|
||||||
func (p *OpenMetricsParser) Histogram() ([]byte, *int64, histogram.Histogram) {
|
func (p *OpenMetricsParser) Histogram() ([]byte, *int64, *histogram.Histogram) {
|
||||||
return nil, nil, histogram.Histogram{}
|
return nil, nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Help returns the metric name and help text in the current entry.
|
// Help returns the metric name and help text in the current entry.
|
||||||
|
|
|
@ -169,10 +169,10 @@ func (p *PromParser) Series() ([]byte, *int64, float64) {
|
||||||
return p.series, nil, p.val
|
return p.series, nil, p.val
|
||||||
}
|
}
|
||||||
|
|
||||||
// Histogram always returns (nil, nil, histogram.Histogram{}) because the
|
// Histogram always returns (nil, nil, nil) because the Prometheus text format
|
||||||
// Prometheus text format does not support sparse histograms.
|
// does not support sparse histograms.
|
||||||
func (p *PromParser) Histogram() ([]byte, *int64, histogram.Histogram) {
|
func (p *PromParser) Histogram() ([]byte, *int64, *histogram.Histogram) {
|
||||||
return nil, nil, histogram.Histogram{}
|
return nil, nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Help returns the metric name and help text in the current entry.
|
// Help returns the metric name and help text in the current entry.
|
||||||
|
|
|
@ -135,7 +135,7 @@ func (p *ProtobufParser) Series() ([]byte, *int64, float64) {
|
||||||
// Histogram returns the bytes of a series with a sparse histogram as a
|
// Histogram returns the bytes of a series with a sparse histogram as a
|
||||||
// value, the timestamp if set, and the sparse histogram in the current
|
// value, the timestamp if set, and the sparse histogram in the current
|
||||||
// sample.
|
// sample.
|
||||||
func (p *ProtobufParser) Histogram() ([]byte, *int64, histogram.Histogram) {
|
func (p *ProtobufParser) Histogram() ([]byte, *int64, *histogram.Histogram) {
|
||||||
var (
|
var (
|
||||||
m = p.mf.GetMetric()[p.metricPos]
|
m = p.mf.GetMetric()[p.metricPos]
|
||||||
ts = m.GetTimestampMs()
|
ts = m.GetTimestampMs()
|
||||||
|
@ -161,12 +161,12 @@ func (p *ProtobufParser) Histogram() ([]byte, *int64, histogram.Histogram) {
|
||||||
sh.NegativeSpans[i].Length = span.GetLength()
|
sh.NegativeSpans[i].Length = span.GetLength()
|
||||||
}
|
}
|
||||||
if ts != 0 {
|
if ts != 0 {
|
||||||
return p.metricBytes.Bytes(), &ts, sh
|
return p.metricBytes.Bytes(), &ts, &sh
|
||||||
}
|
}
|
||||||
// Nasty hack: Assume that ts==0 means no timestamp. That's not true in
|
// Nasty hack: Assume that ts==0 means no timestamp. That's not true in
|
||||||
// general, but proto3 has no distinction between unset and
|
// general, but proto3 has no distinction between unset and
|
||||||
// default. Need to avoid in the final format.
|
// default. Need to avoid in the final format.
|
||||||
return p.metricBytes.Bytes(), nil, sh
|
return p.metricBytes.Bytes(), nil, &sh
|
||||||
}
|
}
|
||||||
|
|
||||||
// Help returns the metric name and help text in the current entry.
|
// Help returns the metric name and help text in the current entry.
|
||||||
|
|
|
@ -266,7 +266,7 @@ metric: <
|
||||||
help string
|
help string
|
||||||
unit string
|
unit string
|
||||||
comment string
|
comment string
|
||||||
shs histogram.Histogram
|
shs *histogram.Histogram
|
||||||
e []exemplar.Exemplar
|
e []exemplar.Exemplar
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
|
@ -332,7 +332,7 @@ metric: <
|
||||||
{
|
{
|
||||||
m: "test_histogram",
|
m: "test_histogram",
|
||||||
t: 1234568,
|
t: 1234568,
|
||||||
shs: histogram.Histogram{
|
shs: &histogram.Histogram{
|
||||||
Count: 175,
|
Count: 175,
|
||||||
ZeroCount: 2,
|
ZeroCount: 2,
|
||||||
Sum: 0.0008280461746287094,
|
Sum: 0.0008280461746287094,
|
||||||
|
|
|
@ -1748,7 +1748,7 @@ func (ev *evaluator) matrixIterSlice(it *storage.BufferedSeriesIterator, mint, m
|
||||||
ev.error(ErrTooManySamples(env))
|
ev.error(ErrTooManySamples(env))
|
||||||
}
|
}
|
||||||
ev.currentSamples++
|
ev.currentSamples++
|
||||||
out = append(out, Point{T: t, H: &h})
|
out = append(out, Point{T: t, H: h})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -1775,7 +1775,7 @@ func (ev *evaluator) matrixIterSlice(it *storage.BufferedSeriesIterator, mint, m
|
||||||
if ev.currentSamples >= ev.maxSamples {
|
if ev.currentSamples >= ev.maxSamples {
|
||||||
ev.error(ErrTooManySamples(env))
|
ev.error(ErrTooManySamples(env))
|
||||||
}
|
}
|
||||||
out = append(out, Point{T: t, H: &h})
|
out = append(out, Point{T: t, H: h})
|
||||||
ev.currentSamples++
|
ev.currentSamples++
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -2460,5 +2460,5 @@ func TestSparseHistogramRate(t *testing.T) {
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
res := qry.Exec(test.Context())
|
res := qry.Exec(test.Context())
|
||||||
require.NoError(t, res.Err)
|
require.NoError(t, res.Err)
|
||||||
fmt.Println(res)
|
// fmt.Println(res)
|
||||||
}
|
}
|
||||||
|
|
|
@ -300,9 +300,9 @@ func (ssi *storageSeriesIterator) At() (t int64, v float64) {
|
||||||
return p.T, p.V
|
return p.T, p.V
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ssi *storageSeriesIterator) AtHistogram() (int64, histogram.Histogram) {
|
func (ssi *storageSeriesIterator) AtHistogram() (int64, *histogram.Histogram) {
|
||||||
p := ssi.points[ssi.curr]
|
p := ssi.points[ssi.curr]
|
||||||
return p.T, *p.H
|
return p.T, p.H
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ssi *storageSeriesIterator) ChunkEncoding() chunkenc.Encoding {
|
func (ssi *storageSeriesIterator) ChunkEncoding() chunkenc.Encoding {
|
||||||
|
|
|
@ -35,7 +35,7 @@ func (a nopAppender) Append(uint64, labels.Labels, int64, float64) (uint64, erro
|
||||||
func (a nopAppender) AppendExemplar(uint64, labels.Labels, exemplar.Exemplar) (uint64, error) {
|
func (a nopAppender) AppendExemplar(uint64, labels.Labels, exemplar.Exemplar) (uint64, error) {
|
||||||
return 0, nil
|
return 0, nil
|
||||||
}
|
}
|
||||||
func (a nopAppender) AppendHistogram(uint64, labels.Labels, int64, histogram.Histogram) (uint64, error) {
|
func (a nopAppender) AppendHistogram(uint64, labels.Labels, int64, *histogram.Histogram) (uint64, error) {
|
||||||
return 0, nil
|
return 0, nil
|
||||||
}
|
}
|
||||||
func (a nopAppender) Commit() error { return nil }
|
func (a nopAppender) Commit() error { return nil }
|
||||||
|
@ -49,7 +49,7 @@ type sample struct {
|
||||||
|
|
||||||
type histogramSample struct {
|
type histogramSample struct {
|
||||||
t int64
|
t int64
|
||||||
h histogram.Histogram
|
h *histogram.Histogram
|
||||||
}
|
}
|
||||||
|
|
||||||
// collectResultAppender records all samples that were added through the appender.
|
// collectResultAppender records all samples that were added through the appender.
|
||||||
|
@ -96,7 +96,7 @@ func (a *collectResultAppender) AppendExemplar(ref uint64, l labels.Labels, e ex
|
||||||
return a.next.AppendExemplar(ref, l, e)
|
return a.next.AppendExemplar(ref, l, e)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *collectResultAppender) AppendHistogram(ref uint64, l labels.Labels, t int64, h histogram.Histogram) (uint64, error) {
|
func (a *collectResultAppender) AppendHistogram(ref uint64, l labels.Labels, t int64, h *histogram.Histogram) (uint64, error) {
|
||||||
a.pendingHistograms = append(a.pendingHistograms, histogramSample{h: h, t: t})
|
a.pendingHistograms = append(a.pendingHistograms, histogramSample{h: h, t: t})
|
||||||
if a.next == nil {
|
if a.next == nil {
|
||||||
return 0, nil
|
return 0, nil
|
||||||
|
|
|
@ -1440,7 +1440,7 @@ loop:
|
||||||
met []byte
|
met []byte
|
||||||
parsedTimestamp *int64
|
parsedTimestamp *int64
|
||||||
val float64
|
val float64
|
||||||
h histogram.Histogram
|
h *histogram.Histogram
|
||||||
)
|
)
|
||||||
if et, err = p.Next(); err != nil {
|
if et, err = p.Next(); err != nil {
|
||||||
if err == io.EOF {
|
if err == io.EOF {
|
||||||
|
|
|
@ -120,7 +120,7 @@ func (b *BufferedSeriesIterator) Next() bool {
|
||||||
// Add current element to buffer before advancing.
|
// Add current element to buffer before advancing.
|
||||||
if b.it.ChunkEncoding() == chunkenc.EncHistogram {
|
if b.it.ChunkEncoding() == chunkenc.EncHistogram {
|
||||||
t, h := b.it.AtHistogram()
|
t, h := b.it.AtHistogram()
|
||||||
b.buf.add(sample{t: t, h: &h})
|
b.buf.add(sample{t: t, h: h})
|
||||||
} else {
|
} else {
|
||||||
t, v := b.it.At()
|
t, v := b.it.At()
|
||||||
b.buf.add(sample{t: t, v: v})
|
b.buf.add(sample{t: t, v: v})
|
||||||
|
@ -144,7 +144,7 @@ func (b *BufferedSeriesIterator) Values() (int64, float64) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// HistogramValues returns the current histogram element of the iterator.
|
// HistogramValues returns the current histogram element of the iterator.
|
||||||
func (b *BufferedSeriesIterator) HistogramValues() (int64, histogram.Histogram) {
|
func (b *BufferedSeriesIterator) HistogramValues() (int64, *histogram.Histogram) {
|
||||||
return b.it.AtHistogram()
|
return b.it.AtHistogram()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -230,7 +230,7 @@ func (it *sampleRingIterator) At() (int64, float64) {
|
||||||
return it.r.at(it.i)
|
return it.r.at(it.i)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (it *sampleRingIterator) AtHistogram() (int64, histogram.Histogram) {
|
func (it *sampleRingIterator) AtHistogram() (int64, *histogram.Histogram) {
|
||||||
return it.r.atHistogram(it.i)
|
return it.r.atHistogram(it.i)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -244,10 +244,10 @@ func (r *sampleRing) at(i int) (int64, float64) {
|
||||||
return s.t, s.v
|
return s.t, s.v
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *sampleRing) atHistogram(i int) (int64, histogram.Histogram) {
|
func (r *sampleRing) atHistogram(i int) (int64, *histogram.Histogram) {
|
||||||
j := (r.f + i) % len(r.buf)
|
j := (r.f + i) % len(r.buf)
|
||||||
s := r.buf[j]
|
s := r.buf[j]
|
||||||
return s.t, *s.h
|
return s.t, s.h
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *sampleRing) atSample(i int) sample {
|
func (r *sampleRing) atSample(i int) sample {
|
||||||
|
|
|
@ -55,7 +55,7 @@ func TestSampleRing(t *testing.T) {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
for _, c := range cases {
|
for _, c := range cases {
|
||||||
r := newSampleRing(c.delta, c.size)
|
r := newSampleRing(c.delta, c.size, chunkenc.EncNone)
|
||||||
|
|
||||||
input := []sample{}
|
input := []sample{}
|
||||||
for _, t := range c.input {
|
for _, t := range c.input {
|
||||||
|
@ -66,7 +66,7 @@ func TestSampleRing(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
for i, s := range input {
|
for i, s := range input {
|
||||||
r.add(s.t, s.v)
|
r.add(s)
|
||||||
buffered := r.samples()
|
buffered := r.samples()
|
||||||
|
|
||||||
for _, sold := range input[:i] {
|
for _, sold := range input[:i] {
|
||||||
|
@ -106,7 +106,7 @@ func TestBufferedSeriesIterator(t *testing.T) {
|
||||||
require.Equal(t, ev, v, "value mismatch")
|
require.Equal(t, ev, v, "value mismatch")
|
||||||
}
|
}
|
||||||
prevSampleEq := func(ets int64, ev float64, eok bool) {
|
prevSampleEq := func(ets int64, ev float64, eok bool) {
|
||||||
ts, v, ok := it.PeekBack(1)
|
ts, v, _, ok := it.PeekBack(1)
|
||||||
require.Equal(t, eok, ok, "exist mismatch")
|
require.Equal(t, eok, ok, "exist mismatch")
|
||||||
require.Equal(t, ets, ts, "timestamp mismatch")
|
require.Equal(t, ets, ts, "timestamp mismatch")
|
||||||
require.Equal(t, ev, v, "value mismatch")
|
require.Equal(t, ev, v, "value mismatch")
|
||||||
|
@ -196,8 +196,8 @@ type mockSeriesIterator struct {
|
||||||
|
|
||||||
func (m *mockSeriesIterator) Seek(t int64) bool { return m.seek(t) }
|
func (m *mockSeriesIterator) Seek(t int64) bool { return m.seek(t) }
|
||||||
func (m *mockSeriesIterator) At() (int64, float64) { return m.at() }
|
func (m *mockSeriesIterator) At() (int64, float64) { return m.at() }
|
||||||
func (m *mockSeriesIterator) AtHistogram() (int64, histogram.Histogram) {
|
func (m *mockSeriesIterator) AtHistogram() (int64, *histogram.Histogram) {
|
||||||
return 0, histogram.Histogram{}
|
return 0, nil
|
||||||
}
|
}
|
||||||
func (m *mockSeriesIterator) ChunkEncoding() chunkenc.Encoding {
|
func (m *mockSeriesIterator) ChunkEncoding() chunkenc.Encoding {
|
||||||
return chunkenc.EncXOR
|
return chunkenc.EncXOR
|
||||||
|
@ -219,8 +219,8 @@ func (it *fakeSeriesIterator) At() (int64, float64) {
|
||||||
return it.idx * it.step, 123 // Value doesn't matter.
|
return it.idx * it.step, 123 // Value doesn't matter.
|
||||||
}
|
}
|
||||||
|
|
||||||
func (it *fakeSeriesIterator) AtHistogram() (int64, histogram.Histogram) {
|
func (it *fakeSeriesIterator) AtHistogram() (int64, *histogram.Histogram) {
|
||||||
return it.idx * it.step, histogram.Histogram{} // Value doesn't matter.
|
return it.idx * it.step, &histogram.Histogram{} // Value doesn't matter.
|
||||||
}
|
}
|
||||||
|
|
||||||
func (it *fakeSeriesIterator) ChunkEncoding() chunkenc.Encoding {
|
func (it *fakeSeriesIterator) ChunkEncoding() chunkenc.Encoding {
|
||||||
|
|
|
@ -173,7 +173,7 @@ func (f *fanoutAppender) AppendExemplar(ref uint64, l labels.Labels, e exemplar.
|
||||||
return ref, nil
|
return ref, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *fanoutAppender) AppendHistogram(ref uint64, l labels.Labels, t int64, h histogram.Histogram) (uint64, error) {
|
func (f *fanoutAppender) AppendHistogram(ref uint64, l labels.Labels, t int64, h *histogram.Histogram) (uint64, error) {
|
||||||
ref, err := f.primary.AppendHistogram(ref, l, t, h)
|
ref, err := f.primary.AppendHistogram(ref, l, t, h)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return ref, err
|
return ref, err
|
||||||
|
|
|
@ -222,7 +222,7 @@ type HistogramAppender interface {
|
||||||
// numbers are ephemeral and may be rejected in calls to Append() at any
|
// numbers are ephemeral and may be rejected in calls to Append() at any
|
||||||
// point. Adding the sample via Append() returns a new reference number.
|
// point. Adding the sample via Append() returns a new reference number.
|
||||||
// If the reference is 0 it must not be used for caching.
|
// If the reference is 0 it must not be used for caching.
|
||||||
AppendHistogram(ref uint64, l labels.Labels, t int64, h histogram.Histogram) (uint64, error)
|
AppendHistogram(ref uint64, l labels.Labels, t int64, h *histogram.Histogram) (uint64, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
// SeriesSet contains a set of series.
|
// SeriesSet contains a set of series.
|
||||||
|
|
|
@ -486,7 +486,7 @@ func (c *chainSampleIterator) At() (t int64, v float64) {
|
||||||
return c.curr.At()
|
return c.curr.At()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *chainSampleIterator) AtHistogram() (int64, histogram.Histogram) {
|
func (c *chainSampleIterator) AtHistogram() (int64, *histogram.Histogram) {
|
||||||
if c.curr == nil {
|
if c.curr == nil {
|
||||||
panic("chainSampleIterator.AtHistogram() called before first .Next() or after .Next() returned false.")
|
panic("chainSampleIterator.AtHistogram() called before first .Next() or after .Next() returned false.")
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,116 +62,116 @@ func TestMergeQuerierWithChainMerger(t *testing.T) {
|
||||||
{
|
{
|
||||||
name: "one querier, two series",
|
name: "one querier, two series",
|
||||||
querierSeries: [][]Series{{
|
querierSeries: [][]Series{{
|
||||||
NewListSeries(labels.FromStrings("bar", "baz"), []tsdbutil.Sample{sample{1, 1}, sample{2, 2}, sample{3, 3}}),
|
NewListSeries(labels.FromStrings("bar", "baz"), []tsdbutil.Sample{sample{1, 1, nil}, sample{2, 2, nil}, sample{3, 3, nil}}),
|
||||||
NewListSeries(labels.FromStrings("foo", "bar"), []tsdbutil.Sample{sample{0, 0}, sample{1, 1}, sample{2, 2}}),
|
NewListSeries(labels.FromStrings("foo", "bar"), []tsdbutil.Sample{sample{0, 0, nil}, sample{1, 1, nil}, sample{2, 2, nil}}),
|
||||||
}},
|
}},
|
||||||
expected: NewMockSeriesSet(
|
expected: NewMockSeriesSet(
|
||||||
NewListSeries(labels.FromStrings("bar", "baz"), []tsdbutil.Sample{sample{1, 1}, sample{2, 2}, sample{3, 3}}),
|
NewListSeries(labels.FromStrings("bar", "baz"), []tsdbutil.Sample{sample{1, 1, nil}, sample{2, 2, nil}, sample{3, 3, nil}}),
|
||||||
NewListSeries(labels.FromStrings("foo", "bar"), []tsdbutil.Sample{sample{0, 0}, sample{1, 1}, sample{2, 2}}),
|
NewListSeries(labels.FromStrings("foo", "bar"), []tsdbutil.Sample{sample{0, 0, nil}, sample{1, 1, nil}, sample{2, 2, nil}}),
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "two queriers, one different series each",
|
name: "two queriers, one different series each",
|
||||||
querierSeries: [][]Series{{
|
querierSeries: [][]Series{{
|
||||||
NewListSeries(labels.FromStrings("bar", "baz"), []tsdbutil.Sample{sample{1, 1}, sample{2, 2}, sample{3, 3}}),
|
NewListSeries(labels.FromStrings("bar", "baz"), []tsdbutil.Sample{sample{1, 1, nil}, sample{2, 2, nil}, sample{3, 3, nil}}),
|
||||||
}, {
|
}, {
|
||||||
NewListSeries(labels.FromStrings("foo", "bar"), []tsdbutil.Sample{sample{0, 0}, sample{1, 1}, sample{2, 2}}),
|
NewListSeries(labels.FromStrings("foo", "bar"), []tsdbutil.Sample{sample{0, 0, nil}, sample{1, 1, nil}, sample{2, 2, nil}}),
|
||||||
}},
|
}},
|
||||||
expected: NewMockSeriesSet(
|
expected: NewMockSeriesSet(
|
||||||
NewListSeries(labels.FromStrings("bar", "baz"), []tsdbutil.Sample{sample{1, 1}, sample{2, 2}, sample{3, 3}}),
|
NewListSeries(labels.FromStrings("bar", "baz"), []tsdbutil.Sample{sample{1, 1, nil}, sample{2, 2, nil}, sample{3, 3, nil}}),
|
||||||
NewListSeries(labels.FromStrings("foo", "bar"), []tsdbutil.Sample{sample{0, 0}, sample{1, 1}, sample{2, 2}}),
|
NewListSeries(labels.FromStrings("foo", "bar"), []tsdbutil.Sample{sample{0, 0, nil}, sample{1, 1, nil}, sample{2, 2, nil}}),
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "two time unsorted queriers, two series each",
|
name: "two time unsorted queriers, two series each",
|
||||||
querierSeries: [][]Series{{
|
querierSeries: [][]Series{{
|
||||||
NewListSeries(labels.FromStrings("bar", "baz"), []tsdbutil.Sample{sample{5, 5}, sample{6, 6}}),
|
NewListSeries(labels.FromStrings("bar", "baz"), []tsdbutil.Sample{sample{5, 5, nil}, sample{6, 6, nil}}),
|
||||||
NewListSeries(labels.FromStrings("foo", "bar"), []tsdbutil.Sample{sample{0, 0}, sample{1, 1}, sample{2, 2}}),
|
NewListSeries(labels.FromStrings("foo", "bar"), []tsdbutil.Sample{sample{0, 0, nil}, sample{1, 1, nil}, sample{2, 2, nil}}),
|
||||||
}, {
|
}, {
|
||||||
NewListSeries(labels.FromStrings("bar", "baz"), []tsdbutil.Sample{sample{1, 1}, sample{2, 2}, sample{3, 3}}),
|
NewListSeries(labels.FromStrings("bar", "baz"), []tsdbutil.Sample{sample{1, 1, nil}, sample{2, 2, nil}, sample{3, 3, nil}}),
|
||||||
NewListSeries(labels.FromStrings("foo", "bar"), []tsdbutil.Sample{sample{3, 3}, sample{4, 4}}),
|
NewListSeries(labels.FromStrings("foo", "bar"), []tsdbutil.Sample{sample{3, 3, nil}, sample{4, 4, nil}}),
|
||||||
}},
|
}},
|
||||||
expected: NewMockSeriesSet(
|
expected: NewMockSeriesSet(
|
||||||
NewListSeries(
|
NewListSeries(
|
||||||
labels.FromStrings("bar", "baz"),
|
labels.FromStrings("bar", "baz"),
|
||||||
[]tsdbutil.Sample{sample{1, 1}, sample{2, 2}, sample{3, 3}, sample{5, 5}, sample{6, 6}},
|
[]tsdbutil.Sample{sample{1, 1, nil}, sample{2, 2, nil}, sample{3, 3, nil}, sample{5, 5, nil}, sample{6, 6, nil}},
|
||||||
),
|
),
|
||||||
NewListSeries(
|
NewListSeries(
|
||||||
labels.FromStrings("foo", "bar"),
|
labels.FromStrings("foo", "bar"),
|
||||||
[]tsdbutil.Sample{sample{0, 0}, sample{1, 1}, sample{2, 2}, sample{3, 3}, sample{4, 4}},
|
[]tsdbutil.Sample{sample{0, 0, nil}, sample{1, 1, nil}, sample{2, 2, nil}, sample{3, 3, nil}, sample{4, 4, nil}},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "five queriers, only two queriers have two time unsorted series each",
|
name: "five queriers, only two queriers have two time unsorted series each",
|
||||||
querierSeries: [][]Series{{}, {}, {
|
querierSeries: [][]Series{{}, {}, {
|
||||||
NewListSeries(labels.FromStrings("bar", "baz"), []tsdbutil.Sample{sample{5, 5}, sample{6, 6}}),
|
NewListSeries(labels.FromStrings("bar", "baz"), []tsdbutil.Sample{sample{5, 5, nil}, sample{6, 6, nil}}),
|
||||||
NewListSeries(labels.FromStrings("foo", "bar"), []tsdbutil.Sample{sample{0, 0}, sample{1, 1}, sample{2, 2}}),
|
NewListSeries(labels.FromStrings("foo", "bar"), []tsdbutil.Sample{sample{0, 0, nil}, sample{1, 1, nil}, sample{2, 2, nil}}),
|
||||||
}, {
|
}, {
|
||||||
NewListSeries(labels.FromStrings("bar", "baz"), []tsdbutil.Sample{sample{1, 1}, sample{2, 2}, sample{3, 3}}),
|
NewListSeries(labels.FromStrings("bar", "baz"), []tsdbutil.Sample{sample{1, 1, nil}, sample{2, 2, nil}, sample{3, 3, nil}}),
|
||||||
NewListSeries(labels.FromStrings("foo", "bar"), []tsdbutil.Sample{sample{3, 3}, sample{4, 4}}),
|
NewListSeries(labels.FromStrings("foo", "bar"), []tsdbutil.Sample{sample{3, 3, nil}, sample{4, 4, nil}}),
|
||||||
}, {}},
|
}, {}},
|
||||||
expected: NewMockSeriesSet(
|
expected: NewMockSeriesSet(
|
||||||
NewListSeries(
|
NewListSeries(
|
||||||
labels.FromStrings("bar", "baz"),
|
labels.FromStrings("bar", "baz"),
|
||||||
[]tsdbutil.Sample{sample{1, 1}, sample{2, 2}, sample{3, 3}, sample{5, 5}, sample{6, 6}},
|
[]tsdbutil.Sample{sample{1, 1, nil}, sample{2, 2, nil}, sample{3, 3, nil}, sample{5, 5, nil}, sample{6, 6, nil}},
|
||||||
),
|
),
|
||||||
NewListSeries(
|
NewListSeries(
|
||||||
labels.FromStrings("foo", "bar"),
|
labels.FromStrings("foo", "bar"),
|
||||||
[]tsdbutil.Sample{sample{0, 0}, sample{1, 1}, sample{2, 2}, sample{3, 3}, sample{4, 4}},
|
[]tsdbutil.Sample{sample{0, 0, nil}, sample{1, 1, nil}, sample{2, 2, nil}, sample{3, 3, nil}, sample{4, 4, nil}},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "two queriers, only two queriers have two time unsorted series each, with 3 noop and one nil querier together",
|
name: "two queriers, only two queriers have two time unsorted series each, with 3 noop and one nil querier together",
|
||||||
querierSeries: [][]Series{{}, {}, {
|
querierSeries: [][]Series{{}, {}, {
|
||||||
NewListSeries(labels.FromStrings("bar", "baz"), []tsdbutil.Sample{sample{5, 5}, sample{6, 6}}),
|
NewListSeries(labels.FromStrings("bar", "baz"), []tsdbutil.Sample{sample{5, 5, nil}, sample{6, 6, nil}}),
|
||||||
NewListSeries(labels.FromStrings("foo", "bar"), []tsdbutil.Sample{sample{0, 0}, sample{1, 1}, sample{2, 2}}),
|
NewListSeries(labels.FromStrings("foo", "bar"), []tsdbutil.Sample{sample{0, 0, nil}, sample{1, 1, nil}, sample{2, 2, nil}}),
|
||||||
}, {
|
}, {
|
||||||
NewListSeries(labels.FromStrings("bar", "baz"), []tsdbutil.Sample{sample{1, 1}, sample{2, 2}, sample{3, 3}}),
|
NewListSeries(labels.FromStrings("bar", "baz"), []tsdbutil.Sample{sample{1, 1, nil}, sample{2, 2, nil}, sample{3, 3, nil}}),
|
||||||
NewListSeries(labels.FromStrings("foo", "bar"), []tsdbutil.Sample{sample{3, 3}, sample{4, 4}}),
|
NewListSeries(labels.FromStrings("foo", "bar"), []tsdbutil.Sample{sample{3, 3, nil}, sample{4, 4, nil}}),
|
||||||
}, {}},
|
}, {}},
|
||||||
extraQueriers: []Querier{NoopQuerier(), NoopQuerier(), nil, NoopQuerier()},
|
extraQueriers: []Querier{NoopQuerier(), NoopQuerier(), nil, NoopQuerier()},
|
||||||
expected: NewMockSeriesSet(
|
expected: NewMockSeriesSet(
|
||||||
NewListSeries(
|
NewListSeries(
|
||||||
labels.FromStrings("bar", "baz"),
|
labels.FromStrings("bar", "baz"),
|
||||||
[]tsdbutil.Sample{sample{1, 1}, sample{2, 2}, sample{3, 3}, sample{5, 5}, sample{6, 6}},
|
[]tsdbutil.Sample{sample{1, 1, nil}, sample{2, 2, nil}, sample{3, 3, nil}, sample{5, 5, nil}, sample{6, 6, nil}},
|
||||||
),
|
),
|
||||||
NewListSeries(
|
NewListSeries(
|
||||||
labels.FromStrings("foo", "bar"),
|
labels.FromStrings("foo", "bar"),
|
||||||
[]tsdbutil.Sample{sample{0, 0}, sample{1, 1}, sample{2, 2}, sample{3, 3}, sample{4, 4}},
|
[]tsdbutil.Sample{sample{0, 0, nil}, sample{1, 1, nil}, sample{2, 2, nil}, sample{3, 3, nil}, sample{4, 4, nil}},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "two queriers, with two series, one is overlapping",
|
name: "two queriers, with two series, one is overlapping",
|
||||||
querierSeries: [][]Series{{}, {}, {
|
querierSeries: [][]Series{{}, {}, {
|
||||||
NewListSeries(labels.FromStrings("bar", "baz"), []tsdbutil.Sample{sample{2, 21}, sample{3, 31}, sample{5, 5}, sample{6, 6}}),
|
NewListSeries(labels.FromStrings("bar", "baz"), []tsdbutil.Sample{sample{2, 21, nil}, sample{3, 31, nil}, sample{5, 5, nil}, sample{6, 6, nil}}),
|
||||||
NewListSeries(labels.FromStrings("foo", "bar"), []tsdbutil.Sample{sample{0, 0}, sample{1, 1}, sample{2, 2}}),
|
NewListSeries(labels.FromStrings("foo", "bar"), []tsdbutil.Sample{sample{0, 0, nil}, sample{1, 1, nil}, sample{2, 2, nil}}),
|
||||||
}, {
|
}, {
|
||||||
NewListSeries(labels.FromStrings("bar", "baz"), []tsdbutil.Sample{sample{1, 1}, sample{2, 22}, sample{3, 32}}),
|
NewListSeries(labels.FromStrings("bar", "baz"), []tsdbutil.Sample{sample{1, 1, nil}, sample{2, 22, nil}, sample{3, 32, nil}}),
|
||||||
NewListSeries(labels.FromStrings("foo", "bar"), []tsdbutil.Sample{sample{3, 3}, sample{4, 4}}),
|
NewListSeries(labels.FromStrings("foo", "bar"), []tsdbutil.Sample{sample{3, 3, nil}, sample{4, 4, nil}}),
|
||||||
}, {}},
|
}, {}},
|
||||||
expected: NewMockSeriesSet(
|
expected: NewMockSeriesSet(
|
||||||
NewListSeries(
|
NewListSeries(
|
||||||
labels.FromStrings("bar", "baz"),
|
labels.FromStrings("bar", "baz"),
|
||||||
[]tsdbutil.Sample{sample{1, 1}, sample{2, 21}, sample{3, 31}, sample{5, 5}, sample{6, 6}},
|
[]tsdbutil.Sample{sample{1, 1, nil}, sample{2, 21, nil}, sample{3, 31, nil}, sample{5, 5, nil}, sample{6, 6, nil}},
|
||||||
),
|
),
|
||||||
NewListSeries(
|
NewListSeries(
|
||||||
labels.FromStrings("foo", "bar"),
|
labels.FromStrings("foo", "bar"),
|
||||||
[]tsdbutil.Sample{sample{0, 0}, sample{1, 1}, sample{2, 2}, sample{3, 3}, sample{4, 4}},
|
[]tsdbutil.Sample{sample{0, 0, nil}, sample{1, 1, nil}, sample{2, 2, nil}, sample{3, 3, nil}, sample{4, 4, nil}},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "two queries, one with NaN samples series",
|
name: "two queries, one with NaN samples series",
|
||||||
querierSeries: [][]Series{{
|
querierSeries: [][]Series{{
|
||||||
NewListSeries(labels.FromStrings("foo", "bar"), []tsdbutil.Sample{sample{0, math.NaN()}}),
|
NewListSeries(labels.FromStrings("foo", "bar"), []tsdbutil.Sample{sample{0, math.NaN(), nil}}),
|
||||||
}, {
|
}, {
|
||||||
NewListSeries(labels.FromStrings("foo", "bar"), []tsdbutil.Sample{sample{1, 1}}),
|
NewListSeries(labels.FromStrings("foo", "bar"), []tsdbutil.Sample{sample{1, 1, nil}}),
|
||||||
}},
|
}},
|
||||||
expected: NewMockSeriesSet(
|
expected: NewMockSeriesSet(
|
||||||
NewListSeries(labels.FromStrings("foo", "bar"), []tsdbutil.Sample{sample{0, math.NaN()}, sample{1, 1}}),
|
NewListSeries(labels.FromStrings("foo", "bar"), []tsdbutil.Sample{sample{0, math.NaN(), nil}, sample{1, 1, nil}}),
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
} {
|
} {
|
||||||
|
@ -245,108 +245,108 @@ func TestMergeChunkQuerierWithNoVerticalChunkSeriesMerger(t *testing.T) {
|
||||||
{
|
{
|
||||||
name: "one querier, two series",
|
name: "one querier, two series",
|
||||||
chkQuerierSeries: [][]ChunkSeries{{
|
chkQuerierSeries: [][]ChunkSeries{{
|
||||||
NewListChunkSeriesFromSamples(labels.FromStrings("bar", "baz"), []tsdbutil.Sample{sample{1, 1}, sample{2, 2}}, []tsdbutil.Sample{sample{3, 3}}),
|
NewListChunkSeriesFromSamples(labels.FromStrings("bar", "baz"), []tsdbutil.Sample{sample{1, 1, nil}, sample{2, 2, nil}}, []tsdbutil.Sample{sample{3, 3, nil}}),
|
||||||
NewListChunkSeriesFromSamples(labels.FromStrings("foo", "bar"), []tsdbutil.Sample{sample{0, 0}, sample{1, 1}}, []tsdbutil.Sample{sample{2, 2}}),
|
NewListChunkSeriesFromSamples(labels.FromStrings("foo", "bar"), []tsdbutil.Sample{sample{0, 0, nil}, sample{1, 1, nil}}, []tsdbutil.Sample{sample{2, 2, nil}}),
|
||||||
}},
|
}},
|
||||||
expected: NewMockChunkSeriesSet(
|
expected: NewMockChunkSeriesSet(
|
||||||
NewListChunkSeriesFromSamples(labels.FromStrings("bar", "baz"), []tsdbutil.Sample{sample{1, 1}, sample{2, 2}}, []tsdbutil.Sample{sample{3, 3}}),
|
NewListChunkSeriesFromSamples(labels.FromStrings("bar", "baz"), []tsdbutil.Sample{sample{1, 1, nil}, sample{2, 2, nil}}, []tsdbutil.Sample{sample{3, 3, nil}}),
|
||||||
NewListChunkSeriesFromSamples(labels.FromStrings("foo", "bar"), []tsdbutil.Sample{sample{0, 0}, sample{1, 1}}, []tsdbutil.Sample{sample{2, 2}}),
|
NewListChunkSeriesFromSamples(labels.FromStrings("foo", "bar"), []tsdbutil.Sample{sample{0, 0, nil}, sample{1, 1, nil}}, []tsdbutil.Sample{sample{2, 2, nil}}),
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "two secondaries, one different series each",
|
name: "two secondaries, one different series each",
|
||||||
chkQuerierSeries: [][]ChunkSeries{{
|
chkQuerierSeries: [][]ChunkSeries{{
|
||||||
NewListChunkSeriesFromSamples(labels.FromStrings("bar", "baz"), []tsdbutil.Sample{sample{1, 1}, sample{2, 2}}, []tsdbutil.Sample{sample{3, 3}}),
|
NewListChunkSeriesFromSamples(labels.FromStrings("bar", "baz"), []tsdbutil.Sample{sample{1, 1, nil}, sample{2, 2, nil}}, []tsdbutil.Sample{sample{3, 3, nil}}),
|
||||||
}, {
|
}, {
|
||||||
NewListChunkSeriesFromSamples(labels.FromStrings("foo", "bar"), []tsdbutil.Sample{sample{0, 0}, sample{1, 1}}, []tsdbutil.Sample{sample{2, 2}}),
|
NewListChunkSeriesFromSamples(labels.FromStrings("foo", "bar"), []tsdbutil.Sample{sample{0, 0, nil}, sample{1, 1, nil}}, []tsdbutil.Sample{sample{2, 2, nil}}),
|
||||||
}},
|
}},
|
||||||
expected: NewMockChunkSeriesSet(
|
expected: NewMockChunkSeriesSet(
|
||||||
NewListChunkSeriesFromSamples(labels.FromStrings("bar", "baz"), []tsdbutil.Sample{sample{1, 1}, sample{2, 2}}, []tsdbutil.Sample{sample{3, 3}}),
|
NewListChunkSeriesFromSamples(labels.FromStrings("bar", "baz"), []tsdbutil.Sample{sample{1, 1, nil}, sample{2, 2, nil}}, []tsdbutil.Sample{sample{3, 3, nil}}),
|
||||||
NewListChunkSeriesFromSamples(labels.FromStrings("foo", "bar"), []tsdbutil.Sample{sample{0, 0}, sample{1, 1}}, []tsdbutil.Sample{sample{2, 2}}),
|
NewListChunkSeriesFromSamples(labels.FromStrings("foo", "bar"), []tsdbutil.Sample{sample{0, 0, nil}, sample{1, 1, nil}}, []tsdbutil.Sample{sample{2, 2, nil}}),
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "two secondaries, two not in time order series each",
|
name: "two secondaries, two not in time order series each",
|
||||||
chkQuerierSeries: [][]ChunkSeries{{
|
chkQuerierSeries: [][]ChunkSeries{{
|
||||||
NewListChunkSeriesFromSamples(labels.FromStrings("bar", "baz"), []tsdbutil.Sample{sample{5, 5}}, []tsdbutil.Sample{sample{6, 6}}),
|
NewListChunkSeriesFromSamples(labels.FromStrings("bar", "baz"), []tsdbutil.Sample{sample{5, 5, nil}}, []tsdbutil.Sample{sample{6, 6, nil}}),
|
||||||
NewListChunkSeriesFromSamples(labels.FromStrings("foo", "bar"), []tsdbutil.Sample{sample{0, 0}, sample{1, 1}}, []tsdbutil.Sample{sample{2, 2}}),
|
NewListChunkSeriesFromSamples(labels.FromStrings("foo", "bar"), []tsdbutil.Sample{sample{0, 0, nil}, sample{1, 1, nil}}, []tsdbutil.Sample{sample{2, 2, nil}}),
|
||||||
}, {
|
}, {
|
||||||
NewListChunkSeriesFromSamples(labels.FromStrings("bar", "baz"), []tsdbutil.Sample{sample{1, 1}, sample{2, 2}}, []tsdbutil.Sample{sample{3, 3}}),
|
NewListChunkSeriesFromSamples(labels.FromStrings("bar", "baz"), []tsdbutil.Sample{sample{1, 1, nil}, sample{2, 2, nil}}, []tsdbutil.Sample{sample{3, 3, nil}}),
|
||||||
NewListChunkSeriesFromSamples(labels.FromStrings("foo", "bar"), []tsdbutil.Sample{sample{3, 3}}, []tsdbutil.Sample{sample{4, 4}}),
|
NewListChunkSeriesFromSamples(labels.FromStrings("foo", "bar"), []tsdbutil.Sample{sample{3, 3, nil}}, []tsdbutil.Sample{sample{4, 4, nil}}),
|
||||||
}},
|
}},
|
||||||
expected: NewMockChunkSeriesSet(
|
expected: NewMockChunkSeriesSet(
|
||||||
NewListChunkSeriesFromSamples(labels.FromStrings("bar", "baz"),
|
NewListChunkSeriesFromSamples(labels.FromStrings("bar", "baz"),
|
||||||
[]tsdbutil.Sample{sample{1, 1}, sample{2, 2}},
|
[]tsdbutil.Sample{sample{1, 1, nil}, sample{2, 2, nil}},
|
||||||
[]tsdbutil.Sample{sample{3, 3}},
|
[]tsdbutil.Sample{sample{3, 3, nil}},
|
||||||
[]tsdbutil.Sample{sample{5, 5}},
|
[]tsdbutil.Sample{sample{5, 5, nil}},
|
||||||
[]tsdbutil.Sample{sample{6, 6}},
|
[]tsdbutil.Sample{sample{6, 6, nil}},
|
||||||
),
|
),
|
||||||
NewListChunkSeriesFromSamples(labels.FromStrings("foo", "bar"),
|
NewListChunkSeriesFromSamples(labels.FromStrings("foo", "bar"),
|
||||||
[]tsdbutil.Sample{sample{0, 0}, sample{1, 1}},
|
[]tsdbutil.Sample{sample{0, 0, nil}, sample{1, 1, nil}},
|
||||||
[]tsdbutil.Sample{sample{2, 2}},
|
[]tsdbutil.Sample{sample{2, 2, nil}},
|
||||||
[]tsdbutil.Sample{sample{3, 3}},
|
[]tsdbutil.Sample{sample{3, 3, nil}},
|
||||||
[]tsdbutil.Sample{sample{4, 4}},
|
[]tsdbutil.Sample{sample{4, 4, nil}},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "five secondaries, only two have two not in time order series each",
|
name: "five secondaries, only two have two not in time order series each",
|
||||||
chkQuerierSeries: [][]ChunkSeries{{}, {}, {
|
chkQuerierSeries: [][]ChunkSeries{{}, {}, {
|
||||||
NewListChunkSeriesFromSamples(labels.FromStrings("bar", "baz"), []tsdbutil.Sample{sample{5, 5}}, []tsdbutil.Sample{sample{6, 6}}),
|
NewListChunkSeriesFromSamples(labels.FromStrings("bar", "baz"), []tsdbutil.Sample{sample{5, 5, nil}}, []tsdbutil.Sample{sample{6, 6, nil}}),
|
||||||
NewListChunkSeriesFromSamples(labels.FromStrings("foo", "bar"), []tsdbutil.Sample{sample{0, 0}, sample{1, 1}}, []tsdbutil.Sample{sample{2, 2}}),
|
NewListChunkSeriesFromSamples(labels.FromStrings("foo", "bar"), []tsdbutil.Sample{sample{0, 0, nil}, sample{1, 1, nil}}, []tsdbutil.Sample{sample{2, 2, nil}}),
|
||||||
}, {
|
}, {
|
||||||
NewListChunkSeriesFromSamples(labels.FromStrings("bar", "baz"), []tsdbutil.Sample{sample{1, 1}, sample{2, 2}}, []tsdbutil.Sample{sample{3, 3}}),
|
NewListChunkSeriesFromSamples(labels.FromStrings("bar", "baz"), []tsdbutil.Sample{sample{1, 1, nil}, sample{2, 2, nil}}, []tsdbutil.Sample{sample{3, 3, nil}}),
|
||||||
NewListChunkSeriesFromSamples(labels.FromStrings("foo", "bar"), []tsdbutil.Sample{sample{3, 3}}, []tsdbutil.Sample{sample{4, 4}}),
|
NewListChunkSeriesFromSamples(labels.FromStrings("foo", "bar"), []tsdbutil.Sample{sample{3, 3, nil}}, []tsdbutil.Sample{sample{4, 4, nil}}),
|
||||||
}, {}},
|
}, {}},
|
||||||
expected: NewMockChunkSeriesSet(
|
expected: NewMockChunkSeriesSet(
|
||||||
NewListChunkSeriesFromSamples(labels.FromStrings("bar", "baz"),
|
NewListChunkSeriesFromSamples(labels.FromStrings("bar", "baz"),
|
||||||
[]tsdbutil.Sample{sample{1, 1}, sample{2, 2}},
|
[]tsdbutil.Sample{sample{1, 1, nil}, sample{2, 2, nil}},
|
||||||
[]tsdbutil.Sample{sample{3, 3}},
|
[]tsdbutil.Sample{sample{3, 3, nil}},
|
||||||
[]tsdbutil.Sample{sample{5, 5}},
|
[]tsdbutil.Sample{sample{5, 5, nil}},
|
||||||
[]tsdbutil.Sample{sample{6, 6}},
|
[]tsdbutil.Sample{sample{6, 6, nil}},
|
||||||
),
|
),
|
||||||
NewListChunkSeriesFromSamples(labels.FromStrings("foo", "bar"),
|
NewListChunkSeriesFromSamples(labels.FromStrings("foo", "bar"),
|
||||||
[]tsdbutil.Sample{sample{0, 0}, sample{1, 1}},
|
[]tsdbutil.Sample{sample{0, 0, nil}, sample{1, 1, nil}},
|
||||||
[]tsdbutil.Sample{sample{2, 2}},
|
[]tsdbutil.Sample{sample{2, 2, nil}},
|
||||||
[]tsdbutil.Sample{sample{3, 3}},
|
[]tsdbutil.Sample{sample{3, 3, nil}},
|
||||||
[]tsdbutil.Sample{sample{4, 4}},
|
[]tsdbutil.Sample{sample{4, 4, nil}},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "two secondaries, with two not in time order series each, with 3 noop queries and one nil together",
|
name: "two secondaries, with two not in time order series each, with 3 noop queries and one nil together",
|
||||||
chkQuerierSeries: [][]ChunkSeries{{
|
chkQuerierSeries: [][]ChunkSeries{{
|
||||||
NewListChunkSeriesFromSamples(labels.FromStrings("bar", "baz"), []tsdbutil.Sample{sample{5, 5}}, []tsdbutil.Sample{sample{6, 6}}),
|
NewListChunkSeriesFromSamples(labels.FromStrings("bar", "baz"), []tsdbutil.Sample{sample{5, 5, nil}}, []tsdbutil.Sample{sample{6, 6, nil}}),
|
||||||
NewListChunkSeriesFromSamples(labels.FromStrings("foo", "bar"), []tsdbutil.Sample{sample{0, 0}, sample{1, 1}}, []tsdbutil.Sample{sample{2, 2}}),
|
NewListChunkSeriesFromSamples(labels.FromStrings("foo", "bar"), []tsdbutil.Sample{sample{0, 0, nil}, sample{1, 1, nil}}, []tsdbutil.Sample{sample{2, 2, nil}}),
|
||||||
}, {
|
}, {
|
||||||
NewListChunkSeriesFromSamples(labels.FromStrings("bar", "baz"), []tsdbutil.Sample{sample{1, 1}, sample{2, 2}}, []tsdbutil.Sample{sample{3, 3}}),
|
NewListChunkSeriesFromSamples(labels.FromStrings("bar", "baz"), []tsdbutil.Sample{sample{1, 1, nil}, sample{2, 2, nil}}, []tsdbutil.Sample{sample{3, 3, nil}}),
|
||||||
NewListChunkSeriesFromSamples(labels.FromStrings("foo", "bar"), []tsdbutil.Sample{sample{3, 3}}, []tsdbutil.Sample{sample{4, 4}}),
|
NewListChunkSeriesFromSamples(labels.FromStrings("foo", "bar"), []tsdbutil.Sample{sample{3, 3, nil}}, []tsdbutil.Sample{sample{4, 4, nil}}),
|
||||||
}},
|
}},
|
||||||
extraQueriers: []ChunkQuerier{NoopChunkedQuerier(), NoopChunkedQuerier(), nil, NoopChunkedQuerier()},
|
extraQueriers: []ChunkQuerier{NoopChunkedQuerier(), NoopChunkedQuerier(), nil, NoopChunkedQuerier()},
|
||||||
expected: NewMockChunkSeriesSet(
|
expected: NewMockChunkSeriesSet(
|
||||||
NewListChunkSeriesFromSamples(labels.FromStrings("bar", "baz"),
|
NewListChunkSeriesFromSamples(labels.FromStrings("bar", "baz"),
|
||||||
[]tsdbutil.Sample{sample{1, 1}, sample{2, 2}},
|
[]tsdbutil.Sample{sample{1, 1, nil}, sample{2, 2, nil}},
|
||||||
[]tsdbutil.Sample{sample{3, 3}},
|
[]tsdbutil.Sample{sample{3, 3, nil}},
|
||||||
[]tsdbutil.Sample{sample{5, 5}},
|
[]tsdbutil.Sample{sample{5, 5, nil}},
|
||||||
[]tsdbutil.Sample{sample{6, 6}},
|
[]tsdbutil.Sample{sample{6, 6, nil}},
|
||||||
),
|
),
|
||||||
NewListChunkSeriesFromSamples(labels.FromStrings("foo", "bar"),
|
NewListChunkSeriesFromSamples(labels.FromStrings("foo", "bar"),
|
||||||
[]tsdbutil.Sample{sample{0, 0}, sample{1, 1}},
|
[]tsdbutil.Sample{sample{0, 0, nil}, sample{1, 1, nil}},
|
||||||
[]tsdbutil.Sample{sample{2, 2}},
|
[]tsdbutil.Sample{sample{2, 2, nil}},
|
||||||
[]tsdbutil.Sample{sample{3, 3}},
|
[]tsdbutil.Sample{sample{3, 3, nil}},
|
||||||
[]tsdbutil.Sample{sample{4, 4}},
|
[]tsdbutil.Sample{sample{4, 4, nil}},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "two queries, one with NaN samples series",
|
name: "two queries, one with NaN samples series",
|
||||||
chkQuerierSeries: [][]ChunkSeries{{
|
chkQuerierSeries: [][]ChunkSeries{{
|
||||||
NewListChunkSeriesFromSamples(labels.FromStrings("foo", "bar"), []tsdbutil.Sample{sample{0, math.NaN()}}),
|
NewListChunkSeriesFromSamples(labels.FromStrings("foo", "bar"), []tsdbutil.Sample{sample{0, math.NaN(), nil}}),
|
||||||
}, {
|
}, {
|
||||||
NewListChunkSeriesFromSamples(labels.FromStrings("foo", "bar"), []tsdbutil.Sample{sample{1, 1}}),
|
NewListChunkSeriesFromSamples(labels.FromStrings("foo", "bar"), []tsdbutil.Sample{sample{1, 1, nil}}),
|
||||||
}},
|
}},
|
||||||
expected: NewMockChunkSeriesSet(
|
expected: NewMockChunkSeriesSet(
|
||||||
NewListChunkSeriesFromSamples(labels.FromStrings("foo", "bar"), []tsdbutil.Sample{sample{0, math.NaN()}}, []tsdbutil.Sample{sample{1, 1}}),
|
NewListChunkSeriesFromSamples(labels.FromStrings("foo", "bar"), []tsdbutil.Sample{sample{0, math.NaN(), nil}}, []tsdbutil.Sample{sample{1, 1, nil}}),
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
} {
|
} {
|
||||||
|
@ -399,9 +399,9 @@ func TestCompactingChunkSeriesMerger(t *testing.T) {
|
||||||
{
|
{
|
||||||
name: "single series",
|
name: "single series",
|
||||||
input: []ChunkSeries{
|
input: []ChunkSeries{
|
||||||
NewListChunkSeriesFromSamples(labels.FromStrings("bar", "baz"), []tsdbutil.Sample{sample{1, 1}, sample{2, 2}}, []tsdbutil.Sample{sample{3, 3}}),
|
NewListChunkSeriesFromSamples(labels.FromStrings("bar", "baz"), []tsdbutil.Sample{sample{1, 1, nil}, sample{2, 2, nil}}, []tsdbutil.Sample{sample{3, 3, nil}}),
|
||||||
},
|
},
|
||||||
expected: NewListChunkSeriesFromSamples(labels.FromStrings("bar", "baz"), []tsdbutil.Sample{sample{1, 1}, sample{2, 2}}, []tsdbutil.Sample{sample{3, 3}}),
|
expected: NewListChunkSeriesFromSamples(labels.FromStrings("bar", "baz"), []tsdbutil.Sample{sample{1, 1, nil}, sample{2, 2, nil}}, []tsdbutil.Sample{sample{3, 3, nil}}),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "two empty series",
|
name: "two empty series",
|
||||||
|
@ -414,55 +414,55 @@ func TestCompactingChunkSeriesMerger(t *testing.T) {
|
||||||
{
|
{
|
||||||
name: "two non overlapping",
|
name: "two non overlapping",
|
||||||
input: []ChunkSeries{
|
input: []ChunkSeries{
|
||||||
NewListChunkSeriesFromSamples(labels.FromStrings("bar", "baz"), []tsdbutil.Sample{sample{1, 1}, sample{2, 2}}, []tsdbutil.Sample{sample{3, 3}, sample{5, 5}}),
|
NewListChunkSeriesFromSamples(labels.FromStrings("bar", "baz"), []tsdbutil.Sample{sample{1, 1, nil}, sample{2, 2, nil}}, []tsdbutil.Sample{sample{3, 3, nil}, sample{5, 5, nil}}),
|
||||||
NewListChunkSeriesFromSamples(labels.FromStrings("bar", "baz"), []tsdbutil.Sample{sample{7, 7}, sample{9, 9}}, []tsdbutil.Sample{sample{10, 10}}),
|
NewListChunkSeriesFromSamples(labels.FromStrings("bar", "baz"), []tsdbutil.Sample{sample{7, 7, nil}, sample{9, 9, nil}}, []tsdbutil.Sample{sample{10, 10, nil}}),
|
||||||
},
|
},
|
||||||
expected: NewListChunkSeriesFromSamples(labels.FromStrings("bar", "baz"), []tsdbutil.Sample{sample{1, 1}, sample{2, 2}}, []tsdbutil.Sample{sample{3, 3}, sample{5, 5}}, []tsdbutil.Sample{sample{7, 7}, sample{9, 9}}, []tsdbutil.Sample{sample{10, 10}}),
|
expected: NewListChunkSeriesFromSamples(labels.FromStrings("bar", "baz"), []tsdbutil.Sample{sample{1, 1, nil}, sample{2, 2, nil}}, []tsdbutil.Sample{sample{3, 3, nil}, sample{5, 5, nil}}, []tsdbutil.Sample{sample{7, 7, nil}, sample{9, 9, nil}}, []tsdbutil.Sample{sample{10, 10, nil}}),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "two overlapping",
|
name: "two overlapping",
|
||||||
input: []ChunkSeries{
|
input: []ChunkSeries{
|
||||||
NewListChunkSeriesFromSamples(labels.FromStrings("bar", "baz"), []tsdbutil.Sample{sample{1, 1}, sample{2, 2}}, []tsdbutil.Sample{sample{3, 3}, sample{8, 8}}),
|
NewListChunkSeriesFromSamples(labels.FromStrings("bar", "baz"), []tsdbutil.Sample{sample{1, 1, nil}, sample{2, 2, nil}}, []tsdbutil.Sample{sample{3, 3, nil}, sample{8, 8, nil}}),
|
||||||
NewListChunkSeriesFromSamples(labels.FromStrings("bar", "baz"), []tsdbutil.Sample{sample{7, 7}, sample{9, 9}}, []tsdbutil.Sample{sample{10, 10}}),
|
NewListChunkSeriesFromSamples(labels.FromStrings("bar", "baz"), []tsdbutil.Sample{sample{7, 7, nil}, sample{9, 9, nil}}, []tsdbutil.Sample{sample{10, 10, nil}}),
|
||||||
},
|
},
|
||||||
expected: NewListChunkSeriesFromSamples(labels.FromStrings("bar", "baz"), []tsdbutil.Sample{sample{1, 1}, sample{2, 2}}, []tsdbutil.Sample{sample{3, 3}, sample{7, 7}, sample{8, 8}, sample{9, 9}}, []tsdbutil.Sample{sample{10, 10}}),
|
expected: NewListChunkSeriesFromSamples(labels.FromStrings("bar", "baz"), []tsdbutil.Sample{sample{1, 1, nil}, sample{2, 2, nil}}, []tsdbutil.Sample{sample{3, 3, nil}, sample{7, 7, nil}, sample{8, 8, nil}, sample{9, 9, nil}}, []tsdbutil.Sample{sample{10, 10, nil}}),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "two duplicated",
|
name: "two duplicated",
|
||||||
input: []ChunkSeries{
|
input: []ChunkSeries{
|
||||||
NewListChunkSeriesFromSamples(labels.FromStrings("bar", "baz"), []tsdbutil.Sample{sample{1, 1}, sample{2, 2}, sample{3, 3}, sample{5, 5}}),
|
NewListChunkSeriesFromSamples(labels.FromStrings("bar", "baz"), []tsdbutil.Sample{sample{1, 1, nil}, sample{2, 2, nil}, sample{3, 3, nil}, sample{5, 5, nil}}),
|
||||||
NewListChunkSeriesFromSamples(labels.FromStrings("bar", "baz"), []tsdbutil.Sample{sample{2, 2}, sample{3, 3}, sample{5, 5}}),
|
NewListChunkSeriesFromSamples(labels.FromStrings("bar", "baz"), []tsdbutil.Sample{sample{2, 2, nil}, sample{3, 3, nil}, sample{5, 5, nil}}),
|
||||||
},
|
},
|
||||||
expected: NewListChunkSeriesFromSamples(labels.FromStrings("bar", "baz"), []tsdbutil.Sample{sample{1, 1}, sample{2, 2}, sample{3, 3}, sample{5, 5}}),
|
expected: NewListChunkSeriesFromSamples(labels.FromStrings("bar", "baz"), []tsdbutil.Sample{sample{1, 1, nil}, sample{2, 2, nil}, sample{3, 3, nil}, sample{5, 5, nil}}),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "three overlapping",
|
name: "three overlapping",
|
||||||
input: []ChunkSeries{
|
input: []ChunkSeries{
|
||||||
NewListChunkSeriesFromSamples(labels.FromStrings("bar", "baz"), []tsdbutil.Sample{sample{1, 1}, sample{2, 2}, sample{3, 3}, sample{5, 5}}),
|
NewListChunkSeriesFromSamples(labels.FromStrings("bar", "baz"), []tsdbutil.Sample{sample{1, 1, nil}, sample{2, 2, nil}, sample{3, 3, nil}, sample{5, 5, nil}}),
|
||||||
NewListChunkSeriesFromSamples(labels.FromStrings("bar", "baz"), []tsdbutil.Sample{sample{2, 2}, sample{3, 3}, sample{6, 6}}),
|
NewListChunkSeriesFromSamples(labels.FromStrings("bar", "baz"), []tsdbutil.Sample{sample{2, 2, nil}, sample{3, 3, nil}, sample{6, 6, nil}}),
|
||||||
NewListChunkSeriesFromSamples(labels.FromStrings("bar", "baz"), []tsdbutil.Sample{sample{0, 0}, sample{4, 4}}),
|
NewListChunkSeriesFromSamples(labels.FromStrings("bar", "baz"), []tsdbutil.Sample{sample{0, 0, nil}, sample{4, 4, nil}}),
|
||||||
},
|
},
|
||||||
expected: NewListChunkSeriesFromSamples(labels.FromStrings("bar", "baz"), []tsdbutil.Sample{sample{0, 0}, sample{1, 1}, sample{2, 2}, sample{3, 3}, sample{4, 4}, sample{5, 5}, sample{6, 6}}),
|
expected: NewListChunkSeriesFromSamples(labels.FromStrings("bar", "baz"), []tsdbutil.Sample{sample{0, 0, nil}, sample{1, 1, nil}, sample{2, 2, nil}, sample{3, 3, nil}, sample{4, 4, nil}, sample{5, 5, nil}, sample{6, 6, nil}}),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "three in chained overlap",
|
name: "three in chained overlap",
|
||||||
input: []ChunkSeries{
|
input: []ChunkSeries{
|
||||||
NewListChunkSeriesFromSamples(labels.FromStrings("bar", "baz"), []tsdbutil.Sample{sample{1, 1}, sample{2, 2}, sample{3, 3}, sample{5, 5}}),
|
NewListChunkSeriesFromSamples(labels.FromStrings("bar", "baz"), []tsdbutil.Sample{sample{1, 1, nil}, sample{2, 2, nil}, sample{3, 3, nil}, sample{5, 5, nil}}),
|
||||||
NewListChunkSeriesFromSamples(labels.FromStrings("bar", "baz"), []tsdbutil.Sample{sample{4, 4}, sample{6, 66}}),
|
NewListChunkSeriesFromSamples(labels.FromStrings("bar", "baz"), []tsdbutil.Sample{sample{4, 4, nil}, sample{6, 66, nil}}),
|
||||||
NewListChunkSeriesFromSamples(labels.FromStrings("bar", "baz"), []tsdbutil.Sample{sample{6, 6}, sample{10, 10}}),
|
NewListChunkSeriesFromSamples(labels.FromStrings("bar", "baz"), []tsdbutil.Sample{sample{6, 6, nil}, sample{10, 10, nil}}),
|
||||||
},
|
},
|
||||||
expected: NewListChunkSeriesFromSamples(labels.FromStrings("bar", "baz"), []tsdbutil.Sample{sample{1, 1}, sample{2, 2}, sample{3, 3}, sample{4, 4}, sample{5, 5}, sample{6, 66}, sample{10, 10}}),
|
expected: NewListChunkSeriesFromSamples(labels.FromStrings("bar", "baz"), []tsdbutil.Sample{sample{1, 1, nil}, sample{2, 2, nil}, sample{3, 3, nil}, sample{4, 4, nil}, sample{5, 5, nil}, sample{6, 66, nil}, sample{10, 10, nil}}),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "three in chained overlap complex",
|
name: "three in chained overlap complex",
|
||||||
input: []ChunkSeries{
|
input: []ChunkSeries{
|
||||||
NewListChunkSeriesFromSamples(labels.FromStrings("bar", "baz"), []tsdbutil.Sample{sample{0, 0}, sample{5, 5}}, []tsdbutil.Sample{sample{10, 10}, sample{15, 15}}),
|
NewListChunkSeriesFromSamples(labels.FromStrings("bar", "baz"), []tsdbutil.Sample{sample{0, 0, nil}, sample{5, 5, nil}}, []tsdbutil.Sample{sample{10, 10, nil}, sample{15, 15, nil}}),
|
||||||
NewListChunkSeriesFromSamples(labels.FromStrings("bar", "baz"), []tsdbutil.Sample{sample{2, 2}, sample{20, 20}}, []tsdbutil.Sample{sample{25, 25}, sample{30, 30}}),
|
NewListChunkSeriesFromSamples(labels.FromStrings("bar", "baz"), []tsdbutil.Sample{sample{2, 2, nil}, sample{20, 20, nil}}, []tsdbutil.Sample{sample{25, 25, nil}, sample{30, 30, nil}}),
|
||||||
NewListChunkSeriesFromSamples(labels.FromStrings("bar", "baz"), []tsdbutil.Sample{sample{18, 18}, sample{26, 26}}, []tsdbutil.Sample{sample{31, 31}, sample{35, 35}}),
|
NewListChunkSeriesFromSamples(labels.FromStrings("bar", "baz"), []tsdbutil.Sample{sample{18, 18, nil}, sample{26, 26, nil}}, []tsdbutil.Sample{sample{31, 31, nil}, sample{35, 35, nil}}),
|
||||||
},
|
},
|
||||||
expected: NewListChunkSeriesFromSamples(labels.FromStrings("bar", "baz"),
|
expected: NewListChunkSeriesFromSamples(labels.FromStrings("bar", "baz"),
|
||||||
[]tsdbutil.Sample{sample{0, 0}, sample{2, 2}, sample{5, 5}, sample{10, 10}, sample{15, 15}, sample{18, 18}, sample{20, 20}, sample{25, 25}, sample{26, 26}, sample{30, 30}},
|
[]tsdbutil.Sample{sample{0, 0, nil}, sample{2, 2, nil}, sample{5, 5, nil}, sample{10, 10, nil}, sample{15, 15, nil}, sample{18, 18, nil}, sample{20, 20, nil}, sample{25, 25, nil}, sample{26, 26, nil}, sample{30, 30, nil}},
|
||||||
[]tsdbutil.Sample{sample{31, 31}, sample{35, 35}},
|
[]tsdbutil.Sample{sample{31, 31, nil}, sample{35, 35, nil}},
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -598,37 +598,37 @@ func TestChainSampleIterator(t *testing.T) {
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
input: []chunkenc.Iterator{
|
input: []chunkenc.Iterator{
|
||||||
NewListSeriesIterator(samples{sample{0, 0}, sample{1, 1}}),
|
NewListSeriesIterator(samples{sample{0, 0, nil}, sample{1, 1, nil}}),
|
||||||
},
|
},
|
||||||
expected: []tsdbutil.Sample{sample{0, 0}, sample{1, 1}},
|
expected: []tsdbutil.Sample{sample{0, 0, nil}, sample{1, 1, nil}},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
input: []chunkenc.Iterator{
|
input: []chunkenc.Iterator{
|
||||||
NewListSeriesIterator(samples{sample{0, 0}, sample{1, 1}}),
|
NewListSeriesIterator(samples{sample{0, 0, nil}, sample{1, 1, nil}}),
|
||||||
NewListSeriesIterator(samples{sample{2, 2}, sample{3, 3}}),
|
NewListSeriesIterator(samples{sample{2, 2, nil}, sample{3, 3, nil}}),
|
||||||
},
|
},
|
||||||
expected: []tsdbutil.Sample{sample{0, 0}, sample{1, 1}, sample{2, 2}, sample{3, 3}},
|
expected: []tsdbutil.Sample{sample{0, 0, nil}, sample{1, 1, nil}, sample{2, 2, nil}, sample{3, 3, nil}},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
input: []chunkenc.Iterator{
|
input: []chunkenc.Iterator{
|
||||||
NewListSeriesIterator(samples{sample{0, 0}, sample{3, 3}}),
|
NewListSeriesIterator(samples{sample{0, 0, nil}, sample{3, 3, nil}}),
|
||||||
NewListSeriesIterator(samples{sample{1, 1}, sample{4, 4}}),
|
NewListSeriesIterator(samples{sample{1, 1, nil}, sample{4, 4, nil}}),
|
||||||
NewListSeriesIterator(samples{sample{2, 2}, sample{5, 5}}),
|
NewListSeriesIterator(samples{sample{2, 2, nil}, sample{5, 5, nil}}),
|
||||||
},
|
},
|
||||||
expected: []tsdbutil.Sample{
|
expected: []tsdbutil.Sample{
|
||||||
sample{0, 0}, sample{1, 1}, sample{2, 2}, sample{3, 3}, sample{4, 4}, sample{5, 5}},
|
sample{0, 0, nil}, sample{1, 1, nil}, sample{2, 2, nil}, sample{3, 3, nil}, sample{4, 4, nil}, sample{5, 5, nil}},
|
||||||
},
|
},
|
||||||
// Overlap.
|
// Overlap.
|
||||||
{
|
{
|
||||||
input: []chunkenc.Iterator{
|
input: []chunkenc.Iterator{
|
||||||
NewListSeriesIterator(samples{sample{0, 0}, sample{1, 1}}),
|
NewListSeriesIterator(samples{sample{0, 0, nil}, sample{1, 1, nil}}),
|
||||||
NewListSeriesIterator(samples{sample{0, 0}, sample{2, 2}}),
|
NewListSeriesIterator(samples{sample{0, 0, nil}, sample{2, 2, nil}}),
|
||||||
NewListSeriesIterator(samples{sample{2, 2}, sample{3, 3}}),
|
NewListSeriesIterator(samples{sample{2, 2, nil}, sample{3, 3, nil}}),
|
||||||
NewListSeriesIterator(samples{}),
|
NewListSeriesIterator(samples{}),
|
||||||
NewListSeriesIterator(samples{}),
|
NewListSeriesIterator(samples{}),
|
||||||
NewListSeriesIterator(samples{}),
|
NewListSeriesIterator(samples{}),
|
||||||
},
|
},
|
||||||
expected: []tsdbutil.Sample{sample{0, 0}, sample{1, 1}, sample{2, 2}, sample{3, 3}},
|
expected: []tsdbutil.Sample{sample{0, 0, nil}, sample{1, 1, nil}, sample{2, 2, nil}, sample{3, 3, nil}},
|
||||||
},
|
},
|
||||||
} {
|
} {
|
||||||
merged := NewChainSampleIterator(tc.input)
|
merged := NewChainSampleIterator(tc.input)
|
||||||
|
@ -646,42 +646,42 @@ func TestChainSampleIteratorSeek(t *testing.T) {
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
input: []chunkenc.Iterator{
|
input: []chunkenc.Iterator{
|
||||||
NewListSeriesIterator(samples{sample{0, 0}, sample{1, 1}, sample{2, 2}}),
|
NewListSeriesIterator(samples{sample{0, 0, nil}, sample{1, 1, nil}, sample{2, 2, nil}}),
|
||||||
},
|
},
|
||||||
seek: 1,
|
seek: 1,
|
||||||
expected: []tsdbutil.Sample{sample{1, 1}, sample{2, 2}},
|
expected: []tsdbutil.Sample{sample{1, 1, nil}, sample{2, 2, nil}},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
input: []chunkenc.Iterator{
|
input: []chunkenc.Iterator{
|
||||||
NewListSeriesIterator(samples{sample{0, 0}, sample{1, 1}}),
|
NewListSeriesIterator(samples{sample{0, 0, nil}, sample{1, 1, nil}}),
|
||||||
NewListSeriesIterator(samples{sample{2, 2}, sample{3, 3}}),
|
NewListSeriesIterator(samples{sample{2, 2, nil}, sample{3, 3, nil}}),
|
||||||
},
|
},
|
||||||
seek: 2,
|
seek: 2,
|
||||||
expected: []tsdbutil.Sample{sample{2, 2}, sample{3, 3}},
|
expected: []tsdbutil.Sample{sample{2, 2, nil}, sample{3, 3, nil}},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
input: []chunkenc.Iterator{
|
input: []chunkenc.Iterator{
|
||||||
NewListSeriesIterator(samples{sample{0, 0}, sample{3, 3}}),
|
NewListSeriesIterator(samples{sample{0, 0, nil}, sample{3, 3, nil}}),
|
||||||
NewListSeriesIterator(samples{sample{1, 1}, sample{4, 4}}),
|
NewListSeriesIterator(samples{sample{1, 1, nil}, sample{4, 4, nil}}),
|
||||||
NewListSeriesIterator(samples{sample{2, 2}, sample{5, 5}}),
|
NewListSeriesIterator(samples{sample{2, 2, nil}, sample{5, 5, nil}}),
|
||||||
},
|
},
|
||||||
seek: 2,
|
seek: 2,
|
||||||
expected: []tsdbutil.Sample{sample{2, 2}, sample{3, 3}, sample{4, 4}, sample{5, 5}},
|
expected: []tsdbutil.Sample{sample{2, 2, nil}, sample{3, 3, nil}, sample{4, 4, nil}, sample{5, 5, nil}},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
input: []chunkenc.Iterator{
|
input: []chunkenc.Iterator{
|
||||||
NewListSeriesIterator(samples{sample{0, 0}, sample{2, 2}, sample{3, 3}}),
|
NewListSeriesIterator(samples{sample{0, 0, nil}, sample{2, 2, nil}, sample{3, 3, nil}}),
|
||||||
NewListSeriesIterator(samples{sample{0, 0}, sample{1, 1}, sample{2, 2}}),
|
NewListSeriesIterator(samples{sample{0, 0, nil}, sample{1, 1, nil}, sample{2, 2, nil}}),
|
||||||
},
|
},
|
||||||
seek: 0,
|
seek: 0,
|
||||||
expected: []tsdbutil.Sample{sample{0, 0}, sample{1, 1}, sample{2, 2}, sample{3, 3}},
|
expected: []tsdbutil.Sample{sample{0, 0, nil}, sample{1, 1, nil}, sample{2, 2, nil}, sample{3, 3, nil}},
|
||||||
},
|
},
|
||||||
} {
|
} {
|
||||||
merged := NewChainSampleIterator(tc.input)
|
merged := NewChainSampleIterator(tc.input)
|
||||||
actual := []tsdbutil.Sample{}
|
actual := []tsdbutil.Sample{}
|
||||||
if merged.Seek(tc.seek) {
|
if merged.Seek(tc.seek) {
|
||||||
t, v := merged.At()
|
t, v := merged.At()
|
||||||
actual = append(actual, sample{t, v})
|
actual = append(actual, sample{t, v, nil})
|
||||||
}
|
}
|
||||||
s, err := ExpandSamples(merged, nil)
|
s, err := ExpandSamples(merged, nil)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
|
@ -370,11 +370,11 @@ func (c *concreteSeriesIterator) At() (t int64, v float64) {
|
||||||
return s.Timestamp, s.Value
|
return s.Timestamp, s.Value
|
||||||
}
|
}
|
||||||
|
|
||||||
// AtHistogram always returns (0, histogram.Histogram{}) because there is no
|
// AtHistogram always returns (0, nil) because there is no support for histogram
|
||||||
// support for histogram values yet.
|
// values yet.
|
||||||
// TODO(beorn7): Fix that for histogram support in remote storage.
|
// TODO(beorn7): Fix that for histogram support in remote storage.
|
||||||
func (c *concreteSeriesIterator) AtHistogram() (int64, histogram.Histogram) {
|
func (c *concreteSeriesIterator) AtHistogram() (int64, *histogram.Histogram) {
|
||||||
return 0, histogram.Histogram{}
|
return 0, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *concreteSeriesIterator) ChunkEncoding() chunkenc.Encoding {
|
func (c *concreteSeriesIterator) ChunkEncoding() chunkenc.Encoding {
|
||||||
|
|
|
@ -241,7 +241,7 @@ func (t *timestampTracker) AppendExemplar(_ uint64, _ labels.Labels, _ exemplar.
|
||||||
return 0, nil
|
return 0, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *timestampTracker) AppendHistogram(_ uint64, _ labels.Labels, ts int64, _ histogram.Histogram) (uint64, error) {
|
func (t *timestampTracker) AppendHistogram(_ uint64, _ labels.Labels, ts int64, _ *histogram.Histogram) (uint64, error) {
|
||||||
t.histograms++
|
t.histograms++
|
||||||
if ts > t.highestTimestamp {
|
if ts > t.highestTimestamp {
|
||||||
t.highestTimestamp = ts
|
t.highestTimestamp = ts
|
||||||
|
|
|
@ -188,7 +188,7 @@ func (m *mockAppendable) AppendExemplar(_ uint64, l labels.Labels, e exemplar.Ex
|
||||||
return 0, nil
|
return 0, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (*mockAppendable) AppendHistogram(ref uint64, l labels.Labels, t int64, h histogram.Histogram) (uint64, error) {
|
func (*mockAppendable) AppendHistogram(ref uint64, l labels.Labels, t int64, h *histogram.Histogram) (uint64, error) {
|
||||||
// TODO(beorn7): Noop until we implement sparse histograms over remote write.
|
// TODO(beorn7): Noop until we implement sparse histograms over remote write.
|
||||||
return 0, nil
|
return 0, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -91,9 +91,9 @@ func (it *listSeriesIterator) At() (int64, float64) {
|
||||||
return s.T(), s.V()
|
return s.T(), s.V()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (it *listSeriesIterator) AtHistogram() (int64, histogram.Histogram) {
|
func (it *listSeriesIterator) AtHistogram() (int64, *histogram.Histogram) {
|
||||||
s := it.samples.Get(it.idx)
|
s := it.samples.Get(it.idx)
|
||||||
return s.T(), *s.H()
|
return s.T(), s.H()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (it *listSeriesIterator) ChunkEncoding() chunkenc.Encoding {
|
func (it *listSeriesIterator) ChunkEncoding() chunkenc.Encoding {
|
||||||
|
@ -302,13 +302,12 @@ func ExpandSamples(iter chunkenc.Iterator, newSampleFn func(t int64, v float64,
|
||||||
}
|
}
|
||||||
|
|
||||||
var result []tsdbutil.Sample
|
var result []tsdbutil.Sample
|
||||||
|
for iter.Next() {
|
||||||
|
// Only after Next() returned true, it is safe to ask for the ChunkEncoding.
|
||||||
if iter.ChunkEncoding() == chunkenc.EncHistogram {
|
if iter.ChunkEncoding() == chunkenc.EncHistogram {
|
||||||
for iter.Next() {
|
|
||||||
t, h := iter.AtHistogram()
|
t, h := iter.AtHistogram()
|
||||||
result = append(result, newSampleFn(t, 0, &h))
|
result = append(result, newSampleFn(t, 0, h))
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
for iter.Next() {
|
|
||||||
t, v := iter.At()
|
t, v := iter.At()
|
||||||
// NaNs can't be compared normally, so substitute for another value.
|
// NaNs can't be compared normally, so substitute for another value.
|
||||||
if math.IsNaN(v) {
|
if math.IsNaN(v) {
|
||||||
|
|
|
@ -179,7 +179,7 @@ func TestCorruptedChunk(t *testing.T) {
|
||||||
require.NoError(t, os.RemoveAll(tmpdir))
|
require.NoError(t, os.RemoveAll(tmpdir))
|
||||||
}()
|
}()
|
||||||
|
|
||||||
series := storage.NewListSeries(labels.FromStrings("a", "b"), []tsdbutil.Sample{sample{1, 1}})
|
series := storage.NewListSeries(labels.FromStrings("a", "b"), []tsdbutil.Sample{sample{1, 1, nil}})
|
||||||
blockDir := createBlock(t, tmpdir, []storage.Series{series})
|
blockDir := createBlock(t, tmpdir, []storage.Series{series})
|
||||||
files, err := sequenceFiles(chunkDir(blockDir))
|
files, err := sequenceFiles(chunkDir(blockDir))
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
@ -226,7 +226,7 @@ func TestLabelValuesWithMatchers(t *testing.T) {
|
||||||
seriesEntries = append(seriesEntries, storage.NewListSeries(labels.Labels{
|
seriesEntries = append(seriesEntries, storage.NewListSeries(labels.Labels{
|
||||||
{Name: "unique", Value: fmt.Sprintf("value%d", i)},
|
{Name: "unique", Value: fmt.Sprintf("value%d", i)},
|
||||||
{Name: "tens", Value: fmt.Sprintf("value%d", i/10)},
|
{Name: "tens", Value: fmt.Sprintf("value%d", i/10)},
|
||||||
}, []tsdbutil.Sample{sample{100, 0}}))
|
}, []tsdbutil.Sample{sample{100, 0, nil}}))
|
||||||
}
|
}
|
||||||
|
|
||||||
blockDir := createBlock(t, tmpdir, seriesEntries)
|
blockDir := createBlock(t, tmpdir, seriesEntries)
|
||||||
|
@ -389,7 +389,7 @@ func BenchmarkLabelValuesWithMatchers(b *testing.B) {
|
||||||
{Name: "unique", Value: fmt.Sprintf("value%d", i)},
|
{Name: "unique", Value: fmt.Sprintf("value%d", i)},
|
||||||
{Name: "tens", Value: fmt.Sprintf("value%d", i/(metricCount/10))},
|
{Name: "tens", Value: fmt.Sprintf("value%d", i/(metricCount/10))},
|
||||||
{Name: "ninety", Value: fmt.Sprintf("value%d", i/(metricCount/10)/9)}, // "0" for the first 90%, then "1"
|
{Name: "ninety", Value: fmt.Sprintf("value%d", i/(metricCount/10)/9)}, // "0" for the first 90%, then "1"
|
||||||
}, []tsdbutil.Sample{sample{100, 0}}))
|
}, []tsdbutil.Sample{sample{100, 0, nil}}))
|
||||||
}
|
}
|
||||||
|
|
||||||
blockDir := createBlock(b, tmpdir, seriesEntries)
|
blockDir := createBlock(b, tmpdir, seriesEntries)
|
||||||
|
@ -427,13 +427,13 @@ func TestLabelNamesWithMatchers(t *testing.T) {
|
||||||
for i := 0; i < 100; i++ {
|
for i := 0; i < 100; i++ {
|
||||||
seriesEntries = append(seriesEntries, storage.NewListSeries(labels.Labels{
|
seriesEntries = append(seriesEntries, storage.NewListSeries(labels.Labels{
|
||||||
{Name: "unique", Value: fmt.Sprintf("value%d", i)},
|
{Name: "unique", Value: fmt.Sprintf("value%d", i)},
|
||||||
}, []tsdbutil.Sample{sample{100, 0}}))
|
}, []tsdbutil.Sample{sample{100, 0, nil}}))
|
||||||
|
|
||||||
if i%10 == 0 {
|
if i%10 == 0 {
|
||||||
seriesEntries = append(seriesEntries, storage.NewListSeries(labels.Labels{
|
seriesEntries = append(seriesEntries, storage.NewListSeries(labels.Labels{
|
||||||
{Name: "unique", Value: fmt.Sprintf("value%d", i)},
|
{Name: "unique", Value: fmt.Sprintf("value%d", i)},
|
||||||
{Name: "tens", Value: fmt.Sprintf("value%d", i/10)},
|
{Name: "tens", Value: fmt.Sprintf("value%d", i/10)},
|
||||||
}, []tsdbutil.Sample{sample{100, 0}}))
|
}, []tsdbutil.Sample{sample{100, 0, nil}}))
|
||||||
}
|
}
|
||||||
|
|
||||||
if i%20 == 0 {
|
if i%20 == 0 {
|
||||||
|
@ -441,7 +441,7 @@ func TestLabelNamesWithMatchers(t *testing.T) {
|
||||||
{Name: "unique", Value: fmt.Sprintf("value%d", i)},
|
{Name: "unique", Value: fmt.Sprintf("value%d", i)},
|
||||||
{Name: "tens", Value: fmt.Sprintf("value%d", i/10)},
|
{Name: "tens", Value: fmt.Sprintf("value%d", i/10)},
|
||||||
{Name: "twenties", Value: fmt.Sprintf("value%d", i/20)},
|
{Name: "twenties", Value: fmt.Sprintf("value%d", i/20)},
|
||||||
}, []tsdbutil.Sample{sample{100, 0}}))
|
}, []tsdbutil.Sample{sample{100, 0, nil}}))
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -82,7 +82,7 @@ type Chunk interface {
|
||||||
// Appender adds sample pairs to a chunk.
|
// Appender adds sample pairs to a chunk.
|
||||||
type Appender interface {
|
type Appender interface {
|
||||||
Append(int64, float64)
|
Append(int64, float64)
|
||||||
AppendHistogram(t int64, h histogram.Histogram)
|
AppendHistogram(t int64, h *histogram.Histogram)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Iterator is a simple iterator that can only get the next value.
|
// Iterator is a simple iterator that can only get the next value.
|
||||||
|
@ -102,8 +102,7 @@ type Iterator interface {
|
||||||
At() (int64, float64)
|
At() (int64, float64)
|
||||||
// AtHistogram returns the current timestamp/histogram pair.
|
// AtHistogram returns the current timestamp/histogram pair.
|
||||||
// Before the iterator has advanced AtHistogram behaviour is unspecified.
|
// Before the iterator has advanced AtHistogram behaviour is unspecified.
|
||||||
// TODO(beorn7): Maybe return *histogram.Histogram? It's a fairly large struct.
|
AtHistogram() (int64, *histogram.Histogram)
|
||||||
AtHistogram() (int64, histogram.Histogram)
|
|
||||||
// Err returns the current error. It should be used only after iterator is
|
// Err returns the current error. It should be used only after iterator is
|
||||||
// exhausted, that is `Next` or `Seek` returns false.
|
// exhausted, that is `Next` or `Seek` returns false.
|
||||||
Err() error
|
Err() error
|
||||||
|
@ -120,8 +119,8 @@ type nopIterator struct{}
|
||||||
|
|
||||||
func (nopIterator) Seek(int64) bool { return false }
|
func (nopIterator) Seek(int64) bool { return false }
|
||||||
func (nopIterator) At() (int64, float64) { return math.MinInt64, 0 }
|
func (nopIterator) At() (int64, float64) { return math.MinInt64, 0 }
|
||||||
func (nopIterator) AtHistogram() (int64, histogram.Histogram) {
|
func (nopIterator) AtHistogram() (int64, *histogram.Histogram) {
|
||||||
return math.MinInt64, histogram.Histogram{}
|
return math.MinInt64, nil
|
||||||
}
|
}
|
||||||
func (nopIterator) Next() bool { return false }
|
func (nopIterator) Next() bool { return false }
|
||||||
func (nopIterator) Err() error { return nil }
|
func (nopIterator) Err() error { return nil }
|
||||||
|
|
|
@ -245,7 +245,7 @@ func (a *HistogramAppender) Append(int64, float64) {
|
||||||
// The method returns an additional boolean set to true if it is not appendable
|
// The method returns an additional boolean set to true if it is not appendable
|
||||||
// because of a counter reset. If the given sample is stale, it is always ok to
|
// because of a counter reset. If the given sample is stale, it is always ok to
|
||||||
// append. If counterReset is true, okToAppend is always false.
|
// append. If counterReset is true, okToAppend is always false.
|
||||||
func (a *HistogramAppender) Appendable(h histogram.Histogram) (
|
func (a *HistogramAppender) Appendable(h *histogram.Histogram) (
|
||||||
positiveInterjections, negativeInterjections []Interjection,
|
positiveInterjections, negativeInterjections []Interjection,
|
||||||
okToAppend bool, counterReset bool,
|
okToAppend bool, counterReset bool,
|
||||||
) {
|
) {
|
||||||
|
@ -369,14 +369,14 @@ func counterResetInAnyBucket(oldBuckets, newBuckets []int64, oldSpans, newSpans
|
||||||
// the histogram is properly structured, e.g. the number of buckets used
|
// the histogram is properly structured, e.g. the number of buckets used
|
||||||
// corresponds to the number conveyed by the span structures. First call
|
// corresponds to the number conveyed by the span structures. First call
|
||||||
// Appendable() and act accordingly!
|
// Appendable() and act accordingly!
|
||||||
func (a *HistogramAppender) AppendHistogram(t int64, h histogram.Histogram) {
|
func (a *HistogramAppender) AppendHistogram(t int64, h *histogram.Histogram) {
|
||||||
var tDelta, cntDelta, zCntDelta int64
|
var tDelta, cntDelta, zCntDelta int64
|
||||||
num := binary.BigEndian.Uint16(a.b.bytes())
|
num := binary.BigEndian.Uint16(a.b.bytes())
|
||||||
|
|
||||||
if value.IsStaleNaN(h.Sum) {
|
if value.IsStaleNaN(h.Sum) {
|
||||||
// Emptying out other fields to write no buckets, and an empty
|
// Emptying out other fields to write no buckets, and an empty
|
||||||
// layout in case of first histogram in the chunk.
|
// layout in case of first histogram in the chunk.
|
||||||
h = histogram.Histogram{Sum: h.Sum}
|
h = &histogram.Histogram{Sum: h.Sum}
|
||||||
}
|
}
|
||||||
|
|
||||||
switch num {
|
switch num {
|
||||||
|
@ -401,7 +401,7 @@ func (a *HistogramAppender) AppendHistogram(t int64, h histogram.Histogram) {
|
||||||
// Now store the actual data.
|
// Now store the actual data.
|
||||||
putVarbitInt(a.b, t)
|
putVarbitInt(a.b, t)
|
||||||
putVarbitUint(a.b, h.Count)
|
putVarbitUint(a.b, h.Count)
|
||||||
putVarbitUint(a.b, h.ZeroCount) //
|
putVarbitUint(a.b, h.ZeroCount)
|
||||||
a.b.writeBits(math.Float64bits(h.Sum), 64)
|
a.b.writeBits(math.Float64bits(h.Sum), 64)
|
||||||
for _, b := range h.PositiveBuckets {
|
for _, b := range h.PositiveBuckets {
|
||||||
putVarbitInt(a.b, b)
|
putVarbitInt(a.b, b)
|
||||||
|
@ -582,11 +582,11 @@ func (it *histogramIterator) ChunkEncoding() Encoding {
|
||||||
return EncHistogram
|
return EncHistogram
|
||||||
}
|
}
|
||||||
|
|
||||||
func (it *histogramIterator) AtHistogram() (int64, histogram.Histogram) {
|
func (it *histogramIterator) AtHistogram() (int64, *histogram.Histogram) {
|
||||||
if value.IsStaleNaN(it.sum) {
|
if value.IsStaleNaN(it.sum) {
|
||||||
return it.t, histogram.Histogram{Sum: it.sum}
|
return it.t, &histogram.Histogram{Sum: it.sum}
|
||||||
}
|
}
|
||||||
return it.t, histogram.Histogram{
|
return it.t, &histogram.Histogram{
|
||||||
Count: it.cnt,
|
Count: it.cnt,
|
||||||
ZeroCount: it.zCnt,
|
ZeroCount: it.zCnt,
|
||||||
Sum: it.sum,
|
Sum: it.sum,
|
||||||
|
|
|
@ -30,7 +30,7 @@ func TestHistogramChunkSameBuckets(t *testing.T) {
|
||||||
require.Equal(t, 0, c.NumSamples())
|
require.Equal(t, 0, c.NumSamples())
|
||||||
|
|
||||||
ts := int64(1234567890)
|
ts := int64(1234567890)
|
||||||
h := histogram.Histogram{
|
h := &histogram.Histogram{
|
||||||
Count: 5,
|
Count: 5,
|
||||||
ZeroCount: 2,
|
ZeroCount: 2,
|
||||||
Sum: 18.4,
|
Sum: 18.4,
|
||||||
|
@ -48,6 +48,7 @@ func TestHistogramChunkSameBuckets(t *testing.T) {
|
||||||
|
|
||||||
// Add an updated histogram.
|
// Add an updated histogram.
|
||||||
ts += 16
|
ts += 16
|
||||||
|
h = h.Copy()
|
||||||
h.Count += 9
|
h.Count += 9
|
||||||
h.ZeroCount++
|
h.ZeroCount++
|
||||||
h.Sum = 24.4
|
h.Sum = 24.4
|
||||||
|
@ -61,6 +62,7 @@ func TestHistogramChunkSameBuckets(t *testing.T) {
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
ts += 14
|
ts += 14
|
||||||
|
h = h.Copy()
|
||||||
h.Count += 13
|
h.Count += 13
|
||||||
h.ZeroCount += 2
|
h.ZeroCount += 2
|
||||||
h.Sum = 24.4
|
h.Sum = 24.4
|
||||||
|
@ -113,7 +115,7 @@ func TestHistogramChunkSameBuckets(t *testing.T) {
|
||||||
|
|
||||||
type res struct {
|
type res struct {
|
||||||
t int64
|
t int64
|
||||||
h histogram.Histogram
|
h *histogram.Histogram
|
||||||
}
|
}
|
||||||
|
|
||||||
// Mimics the scenario described for compareSpans().
|
// Mimics the scenario described for compareSpans().
|
||||||
|
@ -126,7 +128,7 @@ func TestHistogramChunkBucketChanges(t *testing.T) {
|
||||||
require.Equal(t, 0, c.NumSamples())
|
require.Equal(t, 0, c.NumSamples())
|
||||||
|
|
||||||
ts1 := int64(1234567890)
|
ts1 := int64(1234567890)
|
||||||
h1 := histogram.Histogram{
|
h1 := &histogram.Histogram{
|
||||||
Count: 5,
|
Count: 5,
|
||||||
ZeroCount: 2,
|
ZeroCount: 2,
|
||||||
Sum: 18.4,
|
Sum: 18.4,
|
||||||
|
@ -147,7 +149,7 @@ func TestHistogramChunkBucketChanges(t *testing.T) {
|
||||||
|
|
||||||
// Add a new histogram that has expanded buckets.
|
// Add a new histogram that has expanded buckets.
|
||||||
ts2 := ts1 + 16
|
ts2 := ts1 + 16
|
||||||
h2 := h1
|
h2 := h1.Copy()
|
||||||
h2.PositiveSpans = []histogram.Span{
|
h2.PositiveSpans = []histogram.Span{
|
||||||
{Offset: 0, Length: 3},
|
{Offset: 0, Length: 3},
|
||||||
{Offset: 1, Length: 1},
|
{Offset: 1, Length: 1},
|
||||||
|
@ -202,7 +204,7 @@ func TestHistoChunkAppendable(t *testing.T) {
|
||||||
require.Equal(t, 0, c.NumSamples())
|
require.Equal(t, 0, c.NumSamples())
|
||||||
|
|
||||||
ts := int64(1234567890)
|
ts := int64(1234567890)
|
||||||
h1 := histogram.Histogram{
|
h1 := &histogram.Histogram{
|
||||||
Count: 5,
|
Count: 5,
|
||||||
ZeroCount: 2,
|
ZeroCount: 2,
|
||||||
Sum: 18.4,
|
Sum: 18.4,
|
||||||
|
|
|
@ -150,7 +150,7 @@ type xorAppender struct {
|
||||||
trailing uint8
|
trailing uint8
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *xorAppender) AppendHistogram(t int64, h histogram.Histogram) {
|
func (a *xorAppender) AppendHistogram(t int64, h *histogram.Histogram) {
|
||||||
panic("appended a histogram to an xor chunk")
|
panic("appended a histogram to an xor chunk")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -253,8 +253,8 @@ func (it *xorIterator) At() (int64, float64) {
|
||||||
return it.t, it.val
|
return it.t, it.val
|
||||||
}
|
}
|
||||||
|
|
||||||
func (it *xorIterator) AtHistogram() (int64, histogram.Histogram) {
|
func (it *xorIterator) AtHistogram() (int64, *histogram.Histogram) {
|
||||||
panic("cannot call xorIterator.AtHistogram().")
|
panic("cannot call xorIterator.AtHistogram")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (it *xorIterator) ChunkEncoding() Encoding {
|
func (it *xorIterator) ChunkEncoding() Encoding {
|
||||||
|
|
|
@ -1326,20 +1326,20 @@ func TestHeadCompactionWithHistograms(t *testing.T) {
|
||||||
require.NoError(t, head.Init(0))
|
require.NoError(t, head.Init(0))
|
||||||
app := head.Appender(context.Background())
|
app := head.Appender(context.Background())
|
||||||
|
|
||||||
type timedHist struct {
|
type timedHistogram struct {
|
||||||
t int64
|
t int64
|
||||||
h histogram.Histogram
|
h *histogram.Histogram
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ingest samples.
|
// Ingest samples.
|
||||||
numHistograms := 120 * 4
|
numHistograms := 120 * 4
|
||||||
timeStep := DefaultBlockDuration / int64(numHistograms)
|
timeStep := DefaultBlockDuration / int64(numHistograms)
|
||||||
expHists := make([]timedHist, 0, numHistograms)
|
expHists := make([]timedHistogram, 0, numHistograms)
|
||||||
l := labels.Labels{{Name: "a", Value: "b"}}
|
l := labels.Labels{{Name: "a", Value: "b"}}
|
||||||
for i, h := range GenerateTestHistograms(numHistograms) {
|
for i, h := range GenerateTestHistograms(numHistograms) {
|
||||||
_, err := app.AppendHistogram(0, l, int64(i)*timeStep, h)
|
_, err := app.AppendHistogram(0, l, int64(i)*timeStep, h)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
expHists = append(expHists, timedHist{int64(i) * timeStep, h})
|
expHists = append(expHists, timedHistogram{int64(i) * timeStep, h})
|
||||||
}
|
}
|
||||||
require.NoError(t, app.Commit())
|
require.NoError(t, app.Commit())
|
||||||
|
|
||||||
|
@ -1372,10 +1372,10 @@ func TestHeadCompactionWithHistograms(t *testing.T) {
|
||||||
require.False(t, ss.Next())
|
require.False(t, ss.Next())
|
||||||
|
|
||||||
it := s.Iterator()
|
it := s.Iterator()
|
||||||
actHists := make([]timedHist, 0, len(expHists))
|
actHists := make([]timedHistogram, 0, len(expHists))
|
||||||
for it.Next() {
|
for it.Next() {
|
||||||
t, h := it.AtHistogram()
|
t, h := it.AtHistogram()
|
||||||
actHists = append(actHists, timedHist{t, h.Copy()})
|
actHists = append(actHists, timedHistogram{t, h.Copy()})
|
||||||
}
|
}
|
||||||
|
|
||||||
require.Equal(t, expHists, actHists)
|
require.Equal(t, expHists, actHists)
|
||||||
|
@ -1455,7 +1455,7 @@ func TestSparseHistogramSpaceSavings(t *testing.T) {
|
||||||
|
|
||||||
var allSparseSeries []struct {
|
var allSparseSeries []struct {
|
||||||
baseLabels labels.Labels
|
baseLabels labels.Labels
|
||||||
hists []histogram.Histogram
|
hists []*histogram.Histogram
|
||||||
}
|
}
|
||||||
|
|
||||||
for sid, schema := range allSchemas {
|
for sid, schema := range allSchemas {
|
||||||
|
@ -1467,7 +1467,7 @@ func TestSparseHistogramSpaceSavings(t *testing.T) {
|
||||||
}
|
}
|
||||||
allSparseSeries = append(allSparseSeries, struct {
|
allSparseSeries = append(allSparseSeries, struct {
|
||||||
baseLabels labels.Labels
|
baseLabels labels.Labels
|
||||||
hists []histogram.Histogram
|
hists []*histogram.Histogram
|
||||||
}{baseLabels: lbls, hists: generateCustomHistograms(numHistograms, c.numBuckets, c.numSpans, c.gapBetweenSpans, schema)})
|
}{baseLabels: lbls, hists: generateCustomHistograms(numHistograms, c.numBuckets, c.numSpans, c.gapBetweenSpans, schema)})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1613,9 +1613,9 @@ Savings: Index=%.2f%%, Chunks=%.2f%%, Total=%.2f%%
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func generateCustomHistograms(numHists, numBuckets, numSpans, gapBetweenSpans, schema int) (r []histogram.Histogram) {
|
func generateCustomHistograms(numHists, numBuckets, numSpans, gapBetweenSpans, schema int) (r []*histogram.Histogram) {
|
||||||
// First histogram with all the settings.
|
// First histogram with all the settings.
|
||||||
h := histogram.Histogram{
|
h := &histogram.Histogram{
|
||||||
Sum: 1000 * rand.Float64(),
|
Sum: 1000 * rand.Float64(),
|
||||||
Schema: int32(schema),
|
Schema: int32(schema),
|
||||||
}
|
}
|
||||||
|
@ -1708,11 +1708,11 @@ func TestSparseHistogramCompactionAndQuery(t *testing.T) {
|
||||||
})
|
})
|
||||||
db.DisableCompactions()
|
db.DisableCompactions()
|
||||||
|
|
||||||
type timedHist struct {
|
type timedHistogram struct {
|
||||||
t int64
|
t int64
|
||||||
h histogram.Histogram
|
h *histogram.Histogram
|
||||||
}
|
}
|
||||||
expHists := make(map[string][]timedHist)
|
expHists := make(map[string][]timedHistogram)
|
||||||
|
|
||||||
series1Histograms := GenerateTestHistograms(20)
|
series1Histograms := GenerateTestHistograms(20)
|
||||||
series2Histograms := GenerateTestHistograms(20)
|
series2Histograms := GenerateTestHistograms(20)
|
||||||
|
@ -1728,8 +1728,8 @@ func TestSparseHistogramCompactionAndQuery(t *testing.T) {
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
l1, l2 := lbls1.String(), lbls2.String()
|
l1, l2 := lbls1.String(), lbls2.String()
|
||||||
expHists[l1] = append(expHists[l1], timedHist{t: ts, h: series1Histograms[idx1]})
|
expHists[l1] = append(expHists[l1], timedHistogram{t: ts, h: series1Histograms[idx1]})
|
||||||
expHists[l2] = append(expHists[l2], timedHist{t: ts, h: series2Histograms[idx2]})
|
expHists[l2] = append(expHists[l2], timedHistogram{t: ts, h: series2Histograms[idx2]})
|
||||||
}
|
}
|
||||||
|
|
||||||
testQuery := func() {
|
testQuery := func() {
|
||||||
|
@ -1740,13 +1740,13 @@ func TestSparseHistogramCompactionAndQuery(t *testing.T) {
|
||||||
}()
|
}()
|
||||||
|
|
||||||
ss := q.Select(false, nil, labels.MustNewMatcher(labels.MatchRegexp, "a", ".*"))
|
ss := q.Select(false, nil, labels.MustNewMatcher(labels.MatchRegexp, "a", ".*"))
|
||||||
actHists := make(map[string][]timedHist)
|
actHists := make(map[string][]timedHistogram)
|
||||||
for ss.Next() {
|
for ss.Next() {
|
||||||
s := ss.At()
|
s := ss.At()
|
||||||
it := s.Iterator()
|
it := s.Iterator()
|
||||||
for it.Next() {
|
for it.Next() {
|
||||||
ts, h := it.AtHistogram()
|
ts, h := it.AtHistogram()
|
||||||
actHists[s.Labels().String()] = append(actHists[s.Labels().String()], timedHist{ts, h.Copy()})
|
actHists[s.Labels().String()] = append(actHists[s.Labels().String()], timedHistogram{ts, h.Copy()})
|
||||||
}
|
}
|
||||||
require.NoError(t, it.Err())
|
require.NoError(t, it.Err())
|
||||||
}
|
}
|
||||||
|
|
|
@ -420,7 +420,7 @@ Outer:
|
||||||
|
|
||||||
expSamples := make([]tsdbutil.Sample, 0, len(c.remaint))
|
expSamples := make([]tsdbutil.Sample, 0, len(c.remaint))
|
||||||
for _, ts := range c.remaint {
|
for _, ts := range c.remaint {
|
||||||
expSamples = append(expSamples, sample{ts, smpls[ts]})
|
expSamples = append(expSamples, sample{ts, smpls[ts], nil})
|
||||||
}
|
}
|
||||||
|
|
||||||
expss := newMockSeriesSet([]storage.Series{
|
expss := newMockSeriesSet([]storage.Series{
|
||||||
|
@ -536,7 +536,7 @@ func TestSkippingInvalidValuesInSameTxn(t *testing.T) {
|
||||||
ssMap := query(t, q, labels.MustNewMatcher(labels.MatchEqual, "a", "b"))
|
ssMap := query(t, q, labels.MustNewMatcher(labels.MatchEqual, "a", "b"))
|
||||||
|
|
||||||
require.Equal(t, map[string][]tsdbutil.Sample{
|
require.Equal(t, map[string][]tsdbutil.Sample{
|
||||||
labels.New(labels.Label{Name: "a", Value: "b"}).String(): {sample{0, 1}},
|
labels.New(labels.Label{Name: "a", Value: "b"}).String(): {sample{0, 1, nil}},
|
||||||
}, ssMap)
|
}, ssMap)
|
||||||
|
|
||||||
// Append Out of Order Value.
|
// Append Out of Order Value.
|
||||||
|
@ -553,7 +553,7 @@ func TestSkippingInvalidValuesInSameTxn(t *testing.T) {
|
||||||
ssMap = query(t, q, labels.MustNewMatcher(labels.MatchEqual, "a", "b"))
|
ssMap = query(t, q, labels.MustNewMatcher(labels.MatchEqual, "a", "b"))
|
||||||
|
|
||||||
require.Equal(t, map[string][]tsdbutil.Sample{
|
require.Equal(t, map[string][]tsdbutil.Sample{
|
||||||
labels.New(labels.Label{Name: "a", Value: "b"}).String(): {sample{0, 1}, sample{10, 3}},
|
labels.New(labels.Label{Name: "a", Value: "b"}).String(): {sample{0, 1, nil}, sample{10, 3, nil}},
|
||||||
}, ssMap)
|
}, ssMap)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -716,7 +716,7 @@ Outer:
|
||||||
|
|
||||||
expSamples := make([]tsdbutil.Sample, 0, len(c.remaint))
|
expSamples := make([]tsdbutil.Sample, 0, len(c.remaint))
|
||||||
for _, ts := range c.remaint {
|
for _, ts := range c.remaint {
|
||||||
expSamples = append(expSamples, sample{ts, smpls[ts]})
|
expSamples = append(expSamples, sample{ts, smpls[ts], nil})
|
||||||
}
|
}
|
||||||
|
|
||||||
expss := newMockSeriesSet([]storage.Series{
|
expss := newMockSeriesSet([]storage.Series{
|
||||||
|
@ -821,7 +821,7 @@ func TestDB_e2e(t *testing.T) {
|
||||||
for i := 0; i < numDatapoints; i++ {
|
for i := 0; i < numDatapoints; i++ {
|
||||||
v := rand.Float64()
|
v := rand.Float64()
|
||||||
|
|
||||||
series = append(series, sample{ts, v})
|
series = append(series, sample{ts, v, nil})
|
||||||
|
|
||||||
_, err := app.Append(0, lset, ts, v)
|
_, err := app.Append(0, lset, ts, v)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
@ -1066,7 +1066,7 @@ func TestTombstoneClean(t *testing.T) {
|
||||||
|
|
||||||
expSamples := make([]tsdbutil.Sample, 0, len(c.remaint))
|
expSamples := make([]tsdbutil.Sample, 0, len(c.remaint))
|
||||||
for _, ts := range c.remaint {
|
for _, ts := range c.remaint {
|
||||||
expSamples = append(expSamples, sample{ts, smpls[ts]})
|
expSamples = append(expSamples, sample{ts, smpls[ts], nil})
|
||||||
}
|
}
|
||||||
|
|
||||||
expss := newMockSeriesSet([]storage.Series{
|
expss := newMockSeriesSet([]storage.Series{
|
||||||
|
@ -2541,11 +2541,11 @@ func TestDBQueryDoesntSeeAppendsAfterCreation(t *testing.T) {
|
||||||
// TestChunkWriter_ReadAfterWrite ensures that chunk segment are cut at the set segment size and
|
// TestChunkWriter_ReadAfterWrite ensures that chunk segment are cut at the set segment size and
|
||||||
// that the resulted segments includes the expected chunks data.
|
// that the resulted segments includes the expected chunks data.
|
||||||
func TestChunkWriter_ReadAfterWrite(t *testing.T) {
|
func TestChunkWriter_ReadAfterWrite(t *testing.T) {
|
||||||
chk1 := tsdbutil.ChunkFromSamples([]tsdbutil.Sample{sample{1, 1}})
|
chk1 := tsdbutil.ChunkFromSamples([]tsdbutil.Sample{sample{1, 1, nil}})
|
||||||
chk2 := tsdbutil.ChunkFromSamples([]tsdbutil.Sample{sample{1, 2}})
|
chk2 := tsdbutil.ChunkFromSamples([]tsdbutil.Sample{sample{1, 2, nil}})
|
||||||
chk3 := tsdbutil.ChunkFromSamples([]tsdbutil.Sample{sample{1, 3}})
|
chk3 := tsdbutil.ChunkFromSamples([]tsdbutil.Sample{sample{1, 3, nil}})
|
||||||
chk4 := tsdbutil.ChunkFromSamples([]tsdbutil.Sample{sample{1, 4}})
|
chk4 := tsdbutil.ChunkFromSamples([]tsdbutil.Sample{sample{1, 4, nil}})
|
||||||
chk5 := tsdbutil.ChunkFromSamples([]tsdbutil.Sample{sample{1, 5}})
|
chk5 := tsdbutil.ChunkFromSamples([]tsdbutil.Sample{sample{1, 5, nil}})
|
||||||
chunkSize := len(chk1.Chunk.Bytes()) + chunks.MaxChunkLengthFieldSize + chunks.ChunkEncodingSize + crc32.Size
|
chunkSize := len(chk1.Chunk.Bytes()) + chunks.MaxChunkLengthFieldSize + chunks.ChunkEncodingSize + crc32.Size
|
||||||
|
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
|
@ -2746,11 +2746,11 @@ func TestRangeForTimestamp(t *testing.T) {
|
||||||
// Regression test for https://github.com/prometheus/prometheus/pull/6514.
|
// Regression test for https://github.com/prometheus/prometheus/pull/6514.
|
||||||
func TestChunkReader_ConcurrentReads(t *testing.T) {
|
func TestChunkReader_ConcurrentReads(t *testing.T) {
|
||||||
chks := []chunks.Meta{
|
chks := []chunks.Meta{
|
||||||
tsdbutil.ChunkFromSamples([]tsdbutil.Sample{sample{1, 1}}),
|
tsdbutil.ChunkFromSamples([]tsdbutil.Sample{sample{1, 1, nil}}),
|
||||||
tsdbutil.ChunkFromSamples([]tsdbutil.Sample{sample{1, 2}}),
|
tsdbutil.ChunkFromSamples([]tsdbutil.Sample{sample{1, 2, nil}}),
|
||||||
tsdbutil.ChunkFromSamples([]tsdbutil.Sample{sample{1, 3}}),
|
tsdbutil.ChunkFromSamples([]tsdbutil.Sample{sample{1, 3, nil}}),
|
||||||
tsdbutil.ChunkFromSamples([]tsdbutil.Sample{sample{1, 4}}),
|
tsdbutil.ChunkFromSamples([]tsdbutil.Sample{sample{1, 4, nil}}),
|
||||||
tsdbutil.ChunkFromSamples([]tsdbutil.Sample{sample{1, 5}}),
|
tsdbutil.ChunkFromSamples([]tsdbutil.Sample{sample{1, 5, nil}}),
|
||||||
}
|
}
|
||||||
|
|
||||||
tempDir, err := ioutil.TempDir("", "test_chunk_writer")
|
tempDir, err := ioutil.TempDir("", "test_chunk_writer")
|
||||||
|
@ -2815,7 +2815,7 @@ func TestCompactHead(t *testing.T) {
|
||||||
val := rand.Float64()
|
val := rand.Float64()
|
||||||
_, err := app.Append(0, labels.FromStrings("a", "b"), int64(i), val)
|
_, err := app.Append(0, labels.FromStrings("a", "b"), int64(i), val)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
expSamples = append(expSamples, sample{int64(i), val})
|
expSamples = append(expSamples, sample{int64(i), val, nil})
|
||||||
}
|
}
|
||||||
require.NoError(t, app.Commit())
|
require.NoError(t, app.Commit())
|
||||||
|
|
||||||
|
@ -2842,7 +2842,7 @@ func TestCompactHead(t *testing.T) {
|
||||||
series := seriesSet.At().Iterator()
|
series := seriesSet.At().Iterator()
|
||||||
for series.Next() {
|
for series.Next() {
|
||||||
time, val := series.At()
|
time, val := series.At()
|
||||||
actSamples = append(actSamples, sample{int64(time), val})
|
actSamples = append(actSamples, sample{int64(time), val, nil})
|
||||||
}
|
}
|
||||||
require.NoError(t, series.Err())
|
require.NoError(t, series.Err())
|
||||||
}
|
}
|
||||||
|
|
|
@ -1490,7 +1490,7 @@ func (s *stripeSeries) getOrSet(hash uint64, lset labels.Labels, createSeries fu
|
||||||
|
|
||||||
type histogramSample struct {
|
type histogramSample struct {
|
||||||
t int64
|
t int64
|
||||||
h histogram.Histogram
|
h *histogram.Histogram
|
||||||
}
|
}
|
||||||
|
|
||||||
type sample struct {
|
type sample struct {
|
||||||
|
@ -1499,7 +1499,8 @@ type sample struct {
|
||||||
h *histogram.Histogram
|
h *histogram.Histogram
|
||||||
}
|
}
|
||||||
|
|
||||||
func newSample(t int64, v float64) tsdbutil.Sample { return sample{t, v, nil} }
|
func newSample(t int64, v float64, h *histogram.Histogram) tsdbutil.Sample { return sample{t, v, h} }
|
||||||
|
|
||||||
func (s sample) T() int64 { return s.t }
|
func (s sample) T() int64 { return s.t }
|
||||||
func (s sample) V() float64 { return s.v }
|
func (s sample) V() float64 { return s.v }
|
||||||
func (s sample) H() *histogram.Histogram { return s.h }
|
func (s sample) H() *histogram.Histogram { return s.h }
|
||||||
|
@ -1661,9 +1662,9 @@ func (h *Head) updateWALReplayStatusRead(current int) {
|
||||||
h.stats.WALReplayStatus.Current = current
|
h.stats.WALReplayStatus.Current = current
|
||||||
}
|
}
|
||||||
|
|
||||||
func GenerateTestHistograms(n int) (r []histogram.Histogram) {
|
func GenerateTestHistograms(n int) (r []*histogram.Histogram) {
|
||||||
for i := 0; i < n; i++ {
|
for i := 0; i < n; i++ {
|
||||||
r = append(r, histogram.Histogram{
|
r = append(r, &histogram.Histogram{
|
||||||
Count: 5 + uint64(i*4),
|
Count: 5 + uint64(i*4),
|
||||||
ZeroCount: 2 + uint64(i),
|
ZeroCount: 2 + uint64(i),
|
||||||
ZeroThreshold: 0.001,
|
ZeroThreshold: 0.001,
|
||||||
|
|
|
@ -67,7 +67,7 @@ func (a *initAppender) AppendExemplar(ref uint64, l labels.Labels, e exemplar.Ex
|
||||||
return a.app.AppendExemplar(ref, l, e)
|
return a.app.AppendExemplar(ref, l, e)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *initAppender) AppendHistogram(ref uint64, l labels.Labels, t int64, h histogram.Histogram) (uint64, error) {
|
func (a *initAppender) AppendHistogram(ref uint64, l labels.Labels, t int64, h *histogram.Histogram) (uint64, error) {
|
||||||
if a.app != nil {
|
if a.app != nil {
|
||||||
return a.app.AppendHistogram(ref, l, t, h)
|
return a.app.AppendHistogram(ref, l, t, h)
|
||||||
}
|
}
|
||||||
|
@ -270,7 +270,7 @@ func (a *headAppender) Append(ref uint64, lset labels.Labels, t int64, v float64
|
||||||
}
|
}
|
||||||
|
|
||||||
if value.IsStaleNaN(v) && s.histogramSeries {
|
if value.IsStaleNaN(v) && s.histogramSeries {
|
||||||
return a.AppendHistogram(ref, lset, t, histogram.Histogram{Sum: v})
|
return a.AppendHistogram(ref, lset, t, &histogram.Histogram{Sum: v})
|
||||||
}
|
}
|
||||||
|
|
||||||
s.Lock()
|
s.Lock()
|
||||||
|
@ -322,7 +322,7 @@ func (s *memSeries) appendable(t int64, v float64) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
// appendableHistogram checks whether the given sample is valid for appending to the series.
|
// appendableHistogram checks whether the given sample is valid for appending to the series.
|
||||||
func (s *memSeries) appendableHistogram(t int64, sh histogram.Histogram) error {
|
func (s *memSeries) appendableHistogram(t int64, h *histogram.Histogram) error {
|
||||||
c := s.head()
|
c := s.head()
|
||||||
if c == nil {
|
if c == nil {
|
||||||
return nil
|
return nil
|
||||||
|
@ -334,7 +334,7 @@ func (s *memSeries) appendableHistogram(t int64, sh histogram.Histogram) error {
|
||||||
if t < c.maxTime {
|
if t < c.maxTime {
|
||||||
return storage.ErrOutOfOrderSample
|
return storage.ErrOutOfOrderSample
|
||||||
}
|
}
|
||||||
// TODO: do it for histogram.
|
// TODO(beorn7): do it for histogram.
|
||||||
// We are allowing exact duplicates as we can encounter them in valid cases
|
// We are allowing exact duplicates as we can encounter them in valid cases
|
||||||
// like federation and erroring out at that time would be extremely noisy.
|
// like federation and erroring out at that time would be extremely noisy.
|
||||||
//if math.Float64bits(s.sampleBuf[3].v) != math.Float64bits(v) {
|
//if math.Float64bits(s.sampleBuf[3].v) != math.Float64bits(v) {
|
||||||
|
@ -372,7 +372,7 @@ func (a *headAppender) AppendExemplar(ref uint64, _ labels.Labels, e exemplar.Ex
|
||||||
return s.ref, nil
|
return s.ref, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *headAppender) AppendHistogram(ref uint64, lset labels.Labels, t int64, h histogram.Histogram) (uint64, error) {
|
func (a *headAppender) AppendHistogram(ref uint64, lset labels.Labels, t int64, h *histogram.Histogram) (uint64, error) {
|
||||||
if t < a.minValidTime {
|
if t < a.minValidTime {
|
||||||
a.head.metrics.outOfBoundSamples.Inc()
|
a.head.metrics.outOfBoundSamples.Inc()
|
||||||
return 0, storage.ErrOutOfBounds
|
return 0, storage.ErrOutOfBounds
|
||||||
|
@ -606,7 +606,7 @@ func (s *memSeries) append(t int64, v float64, appendID uint64, chunkDiskMapper
|
||||||
|
|
||||||
// appendHistogram adds the histogram.
|
// appendHistogram adds the histogram.
|
||||||
// It is unsafe to call this concurrently with s.iterator(...) without holding the series lock.
|
// It is unsafe to call this concurrently with s.iterator(...) without holding the series lock.
|
||||||
func (s *memSeries) appendHistogram(t int64, h histogram.Histogram, appendID uint64, chunkDiskMapper *chunks.ChunkDiskMapper) (sampleInOrder, chunkCreated bool) {
|
func (s *memSeries) appendHistogram(t int64, h *histogram.Histogram, appendID uint64, chunkDiskMapper *chunks.ChunkDiskMapper) (sampleInOrder, chunkCreated bool) {
|
||||||
// Head controls the execution of recoding, so that we own the proper chunk reference afterwards.
|
// Head controls the execution of recoding, so that we own the proper chunk reference afterwards.
|
||||||
// We check for Appendable before appendPreprocessor because in case it ends up creating a new chunk,
|
// We check for Appendable before appendPreprocessor because in case it ends up creating a new chunk,
|
||||||
// we need to know if there was also a counter reset or not to set the meta properly.
|
// we need to know if there was also a counter reset or not to set the meta properly.
|
||||||
|
|
|
@ -519,7 +519,7 @@ func (it *memSafeIterator) At() (int64, float64) {
|
||||||
return s.t, s.v
|
return s.t, s.v
|
||||||
}
|
}
|
||||||
|
|
||||||
func (it *memSafeIterator) AtHistogram() (int64, histogram.Histogram) {
|
func (it *memSafeIterator) AtHistogram() (int64, *histogram.Histogram) {
|
||||||
if it.total-it.i > 4 {
|
if it.total-it.i > 4 {
|
||||||
return it.Iterator.AtHistogram()
|
return it.Iterator.AtHistogram()
|
||||||
}
|
}
|
||||||
|
|
|
@ -331,11 +331,11 @@ func TestHead_ReadWAL(t *testing.T) {
|
||||||
require.NoError(t, c.Err())
|
require.NoError(t, c.Err())
|
||||||
return x
|
return x
|
||||||
}
|
}
|
||||||
require.Equal(t, []sample{{100, 2}, {101, 5}}, expandChunk(s10.iterator(0, nil, head.chunkDiskMapper, nil)))
|
require.Equal(t, []sample{{100, 2, nil}, {101, 5, nil}}, expandChunk(s10.iterator(0, nil, head.chunkDiskMapper, nil)))
|
||||||
require.Equal(t, []sample{{101, 6}}, expandChunk(s50.iterator(0, nil, head.chunkDiskMapper, nil)))
|
require.Equal(t, []sample{{101, 6, nil}}, expandChunk(s50.iterator(0, nil, head.chunkDiskMapper, nil)))
|
||||||
// The samples before the new series record should be discarded since a duplicate record
|
// The samples before the new series record should be discarded since a duplicate record
|
||||||
// is only possible when old samples were compacted.
|
// is only possible when old samples were compacted.
|
||||||
require.Equal(t, []sample{{101, 7}}, expandChunk(s100.iterator(0, nil, head.chunkDiskMapper, nil)))
|
require.Equal(t, []sample{{101, 7, nil}}, expandChunk(s100.iterator(0, nil, head.chunkDiskMapper, nil)))
|
||||||
|
|
||||||
q, err := head.ExemplarQuerier(context.Background())
|
q, err := head.ExemplarQuerier(context.Background())
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
@ -401,8 +401,8 @@ func TestHead_WALMultiRef(t *testing.T) {
|
||||||
// The samples before the new ref should be discarded since Head truncation
|
// The samples before the new ref should be discarded since Head truncation
|
||||||
// happens only after compacting the Head.
|
// happens only after compacting the Head.
|
||||||
require.Equal(t, map[string][]tsdbutil.Sample{`{foo="bar"}`: {
|
require.Equal(t, map[string][]tsdbutil.Sample{`{foo="bar"}`: {
|
||||||
sample{1700, 3},
|
sample{1700, 3, nil},
|
||||||
sample{2000, 4},
|
sample{2000, 4, nil},
|
||||||
}}, series)
|
}}, series)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -798,7 +798,7 @@ func TestDeleteUntilCurMax(t *testing.T) {
|
||||||
it = exps.Iterator()
|
it = exps.Iterator()
|
||||||
resSamples, err := storage.ExpandSamples(it, newSample)
|
resSamples, err := storage.ExpandSamples(it, newSample)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.Equal(t, []tsdbutil.Sample{sample{11, 1}}, resSamples)
|
require.Equal(t, []tsdbutil.Sample{sample{11, 1, nil}}, resSamples)
|
||||||
for res.Next() {
|
for res.Next() {
|
||||||
}
|
}
|
||||||
require.NoError(t, res.Err())
|
require.NoError(t, res.Err())
|
||||||
|
@ -913,7 +913,7 @@ func TestDelete_e2e(t *testing.T) {
|
||||||
v := rand.Float64()
|
v := rand.Float64()
|
||||||
_, err := app.Append(0, ls, ts, v)
|
_, err := app.Append(0, ls, ts, v)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
series = append(series, sample{ts, v})
|
series = append(series, sample{ts, v, nil})
|
||||||
ts += rand.Int63n(timeInterval) + 1
|
ts += rand.Int63n(timeInterval) + 1
|
||||||
}
|
}
|
||||||
seriesMap[labels.New(l...).String()] = series
|
seriesMap[labels.New(l...).String()] = series
|
||||||
|
@ -2397,7 +2397,7 @@ func TestDataMissingOnQueryDuringCompaction(t *testing.T) {
|
||||||
ref, err = app.Append(ref, labels.FromStrings("a", "b"), ts, float64(i))
|
ref, err = app.Append(ref, labels.FromStrings("a", "b"), ts, float64(i))
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
maxt = ts
|
maxt = ts
|
||||||
expSamples = append(expSamples, sample{ts, float64(i)})
|
expSamples = append(expSamples, sample{ts, float64(i), nil})
|
||||||
}
|
}
|
||||||
require.NoError(t, app.Commit())
|
require.NoError(t, app.Commit())
|
||||||
|
|
||||||
|
@ -2541,7 +2541,7 @@ func TestAppendHistogram(t *testing.T) {
|
||||||
|
|
||||||
type timedHistogram struct {
|
type timedHistogram struct {
|
||||||
t int64
|
t int64
|
||||||
h histogram.Histogram
|
h *histogram.Histogram
|
||||||
}
|
}
|
||||||
expHistograms := make([]timedHistogram, 0, numHistograms)
|
expHistograms := make([]timedHistogram, 0, numHistograms)
|
||||||
for i, h := range GenerateTestHistograms(numHistograms) {
|
for i, h := range GenerateTestHistograms(numHistograms) {
|
||||||
|
@ -2588,7 +2588,7 @@ func TestHistogramInWAL(t *testing.T) {
|
||||||
|
|
||||||
type timedHistogram struct {
|
type timedHistogram struct {
|
||||||
t int64
|
t int64
|
||||||
h histogram.Histogram
|
h *histogram.Histogram
|
||||||
}
|
}
|
||||||
expHistograms := make([]timedHistogram, 0, numHistograms)
|
expHistograms := make([]timedHistogram, 0, numHistograms)
|
||||||
for i, h := range GenerateTestHistograms(numHistograms) {
|
for i, h := range GenerateTestHistograms(numHistograms) {
|
||||||
|
@ -2728,7 +2728,7 @@ func TestChunkSnapshot(t *testing.T) {
|
||||||
// 240 samples should m-map at least 1 chunk.
|
// 240 samples should m-map at least 1 chunk.
|
||||||
for ts := int64(1); ts <= 240; ts++ {
|
for ts := int64(1); ts <= 240; ts++ {
|
||||||
val := rand.Float64()
|
val := rand.Float64()
|
||||||
expSeries[lblStr] = append(expSeries[lblStr], sample{ts, val})
|
expSeries[lblStr] = append(expSeries[lblStr], sample{ts, val, nil})
|
||||||
ref, err := app.Append(0, lbls, ts, val)
|
ref, err := app.Append(0, lbls, ts, val)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
@ -2788,7 +2788,7 @@ func TestChunkSnapshot(t *testing.T) {
|
||||||
// 240 samples should m-map at least 1 chunk.
|
// 240 samples should m-map at least 1 chunk.
|
||||||
for ts := int64(241); ts <= 480; ts++ {
|
for ts := int64(241); ts <= 480; ts++ {
|
||||||
val := rand.Float64()
|
val := rand.Float64()
|
||||||
expSeries[lblStr] = append(expSeries[lblStr], sample{ts, val})
|
expSeries[lblStr] = append(expSeries[lblStr], sample{ts, val, nil})
|
||||||
ref, err := app.Append(0, lbls, ts, val)
|
ref, err := app.Append(0, lbls, ts, val)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
@ -2977,7 +2977,7 @@ func TestHistogramStaleSample(t *testing.T) {
|
||||||
|
|
||||||
type timedHistogram struct {
|
type timedHistogram struct {
|
||||||
t int64
|
t int64
|
||||||
h histogram.Histogram
|
h *histogram.Histogram
|
||||||
}
|
}
|
||||||
expHistograms := make([]timedHistogram, 0, numHistograms)
|
expHistograms := make([]timedHistogram, 0, numHistograms)
|
||||||
|
|
||||||
|
@ -3011,6 +3011,7 @@ func TestHistogramStaleSample(t *testing.T) {
|
||||||
require.True(t, value.IsStaleNaN(ah.h.Sum))
|
require.True(t, value.IsStaleNaN(ah.h.Sum))
|
||||||
// To make require.Equal work.
|
// To make require.Equal work.
|
||||||
ah.h.Sum = 0
|
ah.h.Sum = 0
|
||||||
|
eh.h = eh.h.Copy()
|
||||||
eh.h.Sum = 0
|
eh.h.Sum = 0
|
||||||
}
|
}
|
||||||
require.Equal(t, eh, ah)
|
require.Equal(t, eh, ah)
|
||||||
|
@ -3028,7 +3029,7 @@ func TestHistogramStaleSample(t *testing.T) {
|
||||||
// +1 so that delta-of-delta is not 0.
|
// +1 so that delta-of-delta is not 0.
|
||||||
_, err := app.Append(0, l, 100*int64(len(expHistograms))+1, math.Float64frombits(value.StaleNaN))
|
_, err := app.Append(0, l, 100*int64(len(expHistograms))+1, math.Float64frombits(value.StaleNaN))
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
expHistograms = append(expHistograms, timedHistogram{100*int64(len(expHistograms)) + 1, histogram.Histogram{Sum: math.Float64frombits(value.StaleNaN)}})
|
expHistograms = append(expHistograms, timedHistogram{100*int64(len(expHistograms)) + 1, &histogram.Histogram{Sum: math.Float64frombits(value.StaleNaN)}})
|
||||||
require.NoError(t, app.Commit())
|
require.NoError(t, app.Commit())
|
||||||
|
|
||||||
// Only 1 chunk in the memory, no m-mapped chunk.
|
// Only 1 chunk in the memory, no m-mapped chunk.
|
||||||
|
@ -3050,7 +3051,7 @@ func TestHistogramStaleSample(t *testing.T) {
|
||||||
// +1 so that delta-of-delta is not 0.
|
// +1 so that delta-of-delta is not 0.
|
||||||
_, err = app.Append(0, l, 100*int64(len(expHistograms))+1, math.Float64frombits(value.StaleNaN))
|
_, err = app.Append(0, l, 100*int64(len(expHistograms))+1, math.Float64frombits(value.StaleNaN))
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
expHistograms = append(expHistograms, timedHistogram{100*int64(len(expHistograms)) + 1, histogram.Histogram{Sum: math.Float64frombits(value.StaleNaN)}})
|
expHistograms = append(expHistograms, timedHistogram{100*int64(len(expHistograms)) + 1, &histogram.Histogram{Sum: math.Float64frombits(value.StaleNaN)}})
|
||||||
require.NoError(t, app.Commit())
|
require.NoError(t, app.Commit())
|
||||||
|
|
||||||
// Total 2 chunks, 1 m-mapped.
|
// Total 2 chunks, 1 m-mapped.
|
||||||
|
@ -3069,7 +3070,7 @@ func TestHistogramCounterResetHeader(t *testing.T) {
|
||||||
require.NoError(t, head.Init(0))
|
require.NoError(t, head.Init(0))
|
||||||
|
|
||||||
ts := int64(0)
|
ts := int64(0)
|
||||||
appendHistogram := func(h histogram.Histogram) {
|
appendHistogram := func(h *histogram.Histogram) {
|
||||||
ts++
|
ts++
|
||||||
app := head.Appender(context.Background())
|
app := head.Appender(context.Background())
|
||||||
_, err := app.AppendHistogram(0, l, ts, h)
|
_, err := app.AppendHistogram(0, l, ts, h)
|
||||||
|
|
|
@ -649,9 +649,11 @@ func (p *populateWithDelSeriesIterator) Seek(t int64) bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *populateWithDelSeriesIterator) At() (int64, float64) { return p.curr.At() }
|
func (p *populateWithDelSeriesIterator) At() (int64, float64) { return p.curr.At() }
|
||||||
func (p *populateWithDelSeriesIterator) AtHistogram() (int64, histogram.Histogram) {
|
|
||||||
|
func (p *populateWithDelSeriesIterator) AtHistogram() (int64, *histogram.Histogram) {
|
||||||
return p.curr.AtHistogram()
|
return p.curr.AtHistogram()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *populateWithDelSeriesIterator) ChunkEncoding() chunkenc.Encoding {
|
func (p *populateWithDelSeriesIterator) ChunkEncoding() chunkenc.Encoding {
|
||||||
return p.curr.ChunkEncoding()
|
return p.curr.ChunkEncoding()
|
||||||
}
|
}
|
||||||
|
@ -714,7 +716,7 @@ func (p *populateWithDelChunkSeriesIterator) Next() bool {
|
||||||
var (
|
var (
|
||||||
t int64
|
t int64
|
||||||
v float64
|
v float64
|
||||||
h histogram.Histogram
|
h *histogram.Histogram
|
||||||
)
|
)
|
||||||
if p.currDelIter.ChunkEncoding() == chunkenc.EncHistogram {
|
if p.currDelIter.ChunkEncoding() == chunkenc.EncHistogram {
|
||||||
if hc, ok := p.currChkMeta.Chunk.(*chunkenc.HistogramChunk); ok {
|
if hc, ok := p.currChkMeta.Chunk.(*chunkenc.HistogramChunk); ok {
|
||||||
|
@ -870,7 +872,7 @@ func (it *DeletedIterator) At() (int64, float64) {
|
||||||
return it.Iter.At()
|
return it.Iter.At()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (it *DeletedIterator) AtHistogram() (int64, histogram.Histogram) {
|
func (it *DeletedIterator) AtHistogram() (int64, *histogram.Histogram) {
|
||||||
t, h := it.Iter.AtHistogram()
|
t, h := it.Iter.AtHistogram()
|
||||||
return t, h
|
return t, h
|
||||||
}
|
}
|
||||||
|
|
|
@ -277,24 +277,24 @@ func TestBlockQuerier(t *testing.T) {
|
||||||
ms: []*labels.Matcher{labels.MustNewMatcher(labels.MatchRegexp, "a", ".*")},
|
ms: []*labels.Matcher{labels.MustNewMatcher(labels.MatchRegexp, "a", ".*")},
|
||||||
exp: newMockSeriesSet([]storage.Series{
|
exp: newMockSeriesSet([]storage.Series{
|
||||||
storage.NewListSeries(labels.Labels{{Name: "a", Value: "a"}},
|
storage.NewListSeries(labels.Labels{{Name: "a", Value: "a"}},
|
||||||
[]tsdbutil.Sample{sample{1, 2}, sample{2, 3}, sample{3, 4}, sample{5, 2}, sample{6, 3}, sample{7, 4}},
|
[]tsdbutil.Sample{sample{1, 2, nil}, sample{2, 3, nil}, sample{3, 4, nil}, sample{5, 2, nil}, sample{6, 3, nil}, sample{7, 4, nil}},
|
||||||
),
|
),
|
||||||
storage.NewListSeries(labels.Labels{{Name: "a", Value: "a"}, {Name: "b", Value: "b"}},
|
storage.NewListSeries(labels.Labels{{Name: "a", Value: "a"}, {Name: "b", Value: "b"}},
|
||||||
[]tsdbutil.Sample{sample{1, 1}, sample{2, 2}, sample{3, 3}, sample{5, 3}, sample{6, 6}},
|
[]tsdbutil.Sample{sample{1, 1, nil}, sample{2, 2, nil}, sample{3, 3, nil}, sample{5, 3, nil}, sample{6, 6, nil}},
|
||||||
),
|
),
|
||||||
storage.NewListSeries(labels.Labels{{Name: "b", Value: "b"}},
|
storage.NewListSeries(labels.Labels{{Name: "b", Value: "b"}},
|
||||||
[]tsdbutil.Sample{sample{1, 3}, sample{2, 2}, sample{3, 6}, sample{5, 1}, sample{6, 7}, sample{7, 2}},
|
[]tsdbutil.Sample{sample{1, 3, nil}, sample{2, 2, nil}, sample{3, 6, nil}, sample{5, 1, nil}, sample{6, 7, nil}, sample{7, 2, nil}},
|
||||||
),
|
),
|
||||||
}),
|
}),
|
||||||
expChks: newMockChunkSeriesSet([]storage.ChunkSeries{
|
expChks: newMockChunkSeriesSet([]storage.ChunkSeries{
|
||||||
storage.NewListChunkSeriesFromSamples(labels.Labels{{Name: "a", Value: "a"}},
|
storage.NewListChunkSeriesFromSamples(labels.Labels{{Name: "a", Value: "a"}},
|
||||||
[]tsdbutil.Sample{sample{1, 2}, sample{2, 3}, sample{3, 4}}, []tsdbutil.Sample{sample{5, 2}, sample{6, 3}, sample{7, 4}},
|
[]tsdbutil.Sample{sample{1, 2, nil}, sample{2, 3, nil}, sample{3, 4, nil}}, []tsdbutil.Sample{sample{5, 2, nil}, sample{6, 3, nil}, sample{7, 4, nil}},
|
||||||
),
|
),
|
||||||
storage.NewListChunkSeriesFromSamples(labels.Labels{{Name: "a", Value: "a"}, {Name: "b", Value: "b"}},
|
storage.NewListChunkSeriesFromSamples(labels.Labels{{Name: "a", Value: "a"}, {Name: "b", Value: "b"}},
|
||||||
[]tsdbutil.Sample{sample{1, 1}, sample{2, 2}, sample{3, 3}}, []tsdbutil.Sample{sample{5, 3}, sample{6, 6}},
|
[]tsdbutil.Sample{sample{1, 1, nil}, sample{2, 2, nil}, sample{3, 3, nil}}, []tsdbutil.Sample{sample{5, 3, nil}, sample{6, 6, nil}},
|
||||||
),
|
),
|
||||||
storage.NewListChunkSeriesFromSamples(labels.Labels{{Name: "b", Value: "b"}},
|
storage.NewListChunkSeriesFromSamples(labels.Labels{{Name: "b", Value: "b"}},
|
||||||
[]tsdbutil.Sample{sample{1, 3}, sample{2, 2}, sample{3, 6}}, []tsdbutil.Sample{sample{5, 1}, sample{6, 7}, sample{7, 2}},
|
[]tsdbutil.Sample{sample{1, 3, nil}, sample{2, 2, nil}, sample{3, 6, nil}}, []tsdbutil.Sample{sample{5, 1, nil}, sample{6, 7, nil}, sample{7, 2, nil}},
|
||||||
),
|
),
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
|
@ -304,18 +304,18 @@ func TestBlockQuerier(t *testing.T) {
|
||||||
ms: []*labels.Matcher{labels.MustNewMatcher(labels.MatchEqual, "a", "a")},
|
ms: []*labels.Matcher{labels.MustNewMatcher(labels.MatchEqual, "a", "a")},
|
||||||
exp: newMockSeriesSet([]storage.Series{
|
exp: newMockSeriesSet([]storage.Series{
|
||||||
storage.NewListSeries(labels.Labels{{Name: "a", Value: "a"}},
|
storage.NewListSeries(labels.Labels{{Name: "a", Value: "a"}},
|
||||||
[]tsdbutil.Sample{sample{2, 3}, sample{3, 4}, sample{5, 2}, sample{6, 3}},
|
[]tsdbutil.Sample{sample{2, 3, nil}, sample{3, 4, nil}, sample{5, 2, nil}, sample{6, 3, nil}},
|
||||||
),
|
),
|
||||||
storage.NewListSeries(labels.Labels{{Name: "a", Value: "a"}, {Name: "b", Value: "b"}},
|
storage.NewListSeries(labels.Labels{{Name: "a", Value: "a"}, {Name: "b", Value: "b"}},
|
||||||
[]tsdbutil.Sample{sample{2, 2}, sample{3, 3}, sample{5, 3}, sample{6, 6}},
|
[]tsdbutil.Sample{sample{2, 2, nil}, sample{3, 3, nil}, sample{5, 3, nil}, sample{6, 6, nil}},
|
||||||
),
|
),
|
||||||
}),
|
}),
|
||||||
expChks: newMockChunkSeriesSet([]storage.ChunkSeries{
|
expChks: newMockChunkSeriesSet([]storage.ChunkSeries{
|
||||||
storage.NewListChunkSeriesFromSamples(labels.Labels{{Name: "a", Value: "a"}},
|
storage.NewListChunkSeriesFromSamples(labels.Labels{{Name: "a", Value: "a"}},
|
||||||
[]tsdbutil.Sample{sample{2, 3}, sample{3, 4}}, []tsdbutil.Sample{sample{5, 2}, sample{6, 3}},
|
[]tsdbutil.Sample{sample{2, 3, nil}, sample{3, 4, nil}}, []tsdbutil.Sample{sample{5, 2, nil}, sample{6, 3, nil}},
|
||||||
),
|
),
|
||||||
storage.NewListChunkSeriesFromSamples(labels.Labels{{Name: "a", Value: "a"}, {Name: "b", Value: "b"}},
|
storage.NewListChunkSeriesFromSamples(labels.Labels{{Name: "a", Value: "a"}, {Name: "b", Value: "b"}},
|
||||||
[]tsdbutil.Sample{sample{2, 2}, sample{3, 3}}, []tsdbutil.Sample{sample{5, 3}, sample{6, 6}},
|
[]tsdbutil.Sample{sample{2, 2, nil}, sample{3, 3, nil}}, []tsdbutil.Sample{sample{5, 3, nil}, sample{6, 6, nil}},
|
||||||
),
|
),
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
|
@ -363,24 +363,24 @@ func TestBlockQuerier_AgainstHeadWithOpenChunks(t *testing.T) {
|
||||||
ms: []*labels.Matcher{labels.MustNewMatcher(labels.MatchRegexp, "a", ".*")},
|
ms: []*labels.Matcher{labels.MustNewMatcher(labels.MatchRegexp, "a", ".*")},
|
||||||
exp: newMockSeriesSet([]storage.Series{
|
exp: newMockSeriesSet([]storage.Series{
|
||||||
storage.NewListSeries(labels.Labels{{Name: "a", Value: "a"}},
|
storage.NewListSeries(labels.Labels{{Name: "a", Value: "a"}},
|
||||||
[]tsdbutil.Sample{sample{1, 2}, sample{2, 3}, sample{3, 4}, sample{5, 2}, sample{6, 3}, sample{7, 4}},
|
[]tsdbutil.Sample{sample{1, 2, nil}, sample{2, 3, nil}, sample{3, 4, nil}, sample{5, 2, nil}, sample{6, 3, nil}, sample{7, 4, nil}},
|
||||||
),
|
),
|
||||||
storage.NewListSeries(labels.Labels{{Name: "a", Value: "a"}, {Name: "b", Value: "b"}},
|
storage.NewListSeries(labels.Labels{{Name: "a", Value: "a"}, {Name: "b", Value: "b"}},
|
||||||
[]tsdbutil.Sample{sample{1, 1}, sample{2, 2}, sample{3, 3}, sample{5, 3}, sample{6, 6}},
|
[]tsdbutil.Sample{sample{1, 1, nil}, sample{2, 2, nil}, sample{3, 3, nil}, sample{5, 3, nil}, sample{6, 6, nil}},
|
||||||
),
|
),
|
||||||
storage.NewListSeries(labels.Labels{{Name: "b", Value: "b"}},
|
storage.NewListSeries(labels.Labels{{Name: "b", Value: "b"}},
|
||||||
[]tsdbutil.Sample{sample{1, 3}, sample{2, 2}, sample{3, 6}, sample{5, 1}, sample{6, 7}, sample{7, 2}},
|
[]tsdbutil.Sample{sample{1, 3, nil}, sample{2, 2, nil}, sample{3, 6, nil}, sample{5, 1, nil}, sample{6, 7, nil}, sample{7, 2, nil}},
|
||||||
),
|
),
|
||||||
}),
|
}),
|
||||||
expChks: newMockChunkSeriesSet([]storage.ChunkSeries{
|
expChks: newMockChunkSeriesSet([]storage.ChunkSeries{
|
||||||
storage.NewListChunkSeriesFromSamples(labels.Labels{{Name: "a", Value: "a"}},
|
storage.NewListChunkSeriesFromSamples(labels.Labels{{Name: "a", Value: "a"}},
|
||||||
[]tsdbutil.Sample{sample{1, 2}, sample{2, 3}, sample{3, 4}, sample{5, 2}, sample{6, 3}, sample{7, 4}},
|
[]tsdbutil.Sample{sample{1, 2, nil}, sample{2, 3, nil}, sample{3, 4, nil}, sample{5, 2, nil}, sample{6, 3, nil}, sample{7, 4, nil}},
|
||||||
),
|
),
|
||||||
storage.NewListChunkSeriesFromSamples(labels.Labels{{Name: "a", Value: "a"}, {Name: "b", Value: "b"}},
|
storage.NewListChunkSeriesFromSamples(labels.Labels{{Name: "a", Value: "a"}, {Name: "b", Value: "b"}},
|
||||||
[]tsdbutil.Sample{sample{1, 1}, sample{2, 2}, sample{3, 3}, sample{5, 3}, sample{6, 6}},
|
[]tsdbutil.Sample{sample{1, 1, nil}, sample{2, 2, nil}, sample{3, 3, nil}, sample{5, 3, nil}, sample{6, 6, nil}},
|
||||||
),
|
),
|
||||||
storage.NewListChunkSeriesFromSamples(labels.Labels{{Name: "b", Value: "b"}},
|
storage.NewListChunkSeriesFromSamples(labels.Labels{{Name: "b", Value: "b"}},
|
||||||
[]tsdbutil.Sample{sample{1, 3}, sample{2, 2}, sample{3, 6}, sample{5, 1}, sample{6, 7}, sample{7, 2}},
|
[]tsdbutil.Sample{sample{1, 3, nil}, sample{2, 2, nil}, sample{3, 6, nil}, sample{5, 1, nil}, sample{6, 7, nil}, sample{7, 2, nil}},
|
||||||
),
|
),
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
|
@ -390,18 +390,18 @@ func TestBlockQuerier_AgainstHeadWithOpenChunks(t *testing.T) {
|
||||||
ms: []*labels.Matcher{labels.MustNewMatcher(labels.MatchEqual, "a", "a")},
|
ms: []*labels.Matcher{labels.MustNewMatcher(labels.MatchEqual, "a", "a")},
|
||||||
exp: newMockSeriesSet([]storage.Series{
|
exp: newMockSeriesSet([]storage.Series{
|
||||||
storage.NewListSeries(labels.Labels{{Name: "a", Value: "a"}},
|
storage.NewListSeries(labels.Labels{{Name: "a", Value: "a"}},
|
||||||
[]tsdbutil.Sample{sample{2, 3}, sample{3, 4}, sample{5, 2}, sample{6, 3}},
|
[]tsdbutil.Sample{sample{2, 3, nil}, sample{3, 4, nil}, sample{5, 2, nil}, sample{6, 3, nil}},
|
||||||
),
|
),
|
||||||
storage.NewListSeries(labels.Labels{{Name: "a", Value: "a"}, {Name: "b", Value: "b"}},
|
storage.NewListSeries(labels.Labels{{Name: "a", Value: "a"}, {Name: "b", Value: "b"}},
|
||||||
[]tsdbutil.Sample{sample{2, 2}, sample{3, 3}, sample{5, 3}, sample{6, 6}},
|
[]tsdbutil.Sample{sample{2, 2, nil}, sample{3, 3, nil}, sample{5, 3, nil}, sample{6, 6, nil}},
|
||||||
),
|
),
|
||||||
}),
|
}),
|
||||||
expChks: newMockChunkSeriesSet([]storage.ChunkSeries{
|
expChks: newMockChunkSeriesSet([]storage.ChunkSeries{
|
||||||
storage.NewListChunkSeriesFromSamples(labels.Labels{{Name: "a", Value: "a"}},
|
storage.NewListChunkSeriesFromSamples(labels.Labels{{Name: "a", Value: "a"}},
|
||||||
[]tsdbutil.Sample{sample{2, 3}, sample{3, 4}, sample{5, 2}, sample{6, 3}},
|
[]tsdbutil.Sample{sample{2, 3, nil}, sample{3, 4, nil}, sample{5, 2, nil}, sample{6, 3, nil}},
|
||||||
),
|
),
|
||||||
storage.NewListChunkSeriesFromSamples(labels.Labels{{Name: "a", Value: "a"}, {Name: "b", Value: "b"}},
|
storage.NewListChunkSeriesFromSamples(labels.Labels{{Name: "a", Value: "a"}, {Name: "b", Value: "b"}},
|
||||||
[]tsdbutil.Sample{sample{2, 2}, sample{3, 3}, sample{5, 3}, sample{6, 6}},
|
[]tsdbutil.Sample{sample{2, 2, nil}, sample{3, 3, nil}, sample{5, 3, nil}, sample{6, 6, nil}},
|
||||||
),
|
),
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
|
@ -442,22 +442,22 @@ var testData = []seriesSamples{
|
||||||
{
|
{
|
||||||
lset: map[string]string{"a": "a"},
|
lset: map[string]string{"a": "a"},
|
||||||
chunks: [][]sample{
|
chunks: [][]sample{
|
||||||
{{1, 2}, {2, 3}, {3, 4}},
|
{{1, 2, nil}, {2, 3, nil}, {3, 4, nil}},
|
||||||
{{5, 2}, {6, 3}, {7, 4}},
|
{{5, 2, nil}, {6, 3, nil}, {7, 4, nil}},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
lset: map[string]string{"a": "a", "b": "b"},
|
lset: map[string]string{"a": "a", "b": "b"},
|
||||||
chunks: [][]sample{
|
chunks: [][]sample{
|
||||||
{{1, 1}, {2, 2}, {3, 3}},
|
{{1, 1, nil}, {2, 2, nil}, {3, 3, nil}},
|
||||||
{{5, 3}, {6, 6}},
|
{{5, 3, nil}, {6, 6, nil}},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
lset: map[string]string{"b": "b"},
|
lset: map[string]string{"b": "b"},
|
||||||
chunks: [][]sample{
|
chunks: [][]sample{
|
||||||
{{1, 3}, {2, 2}, {3, 6}},
|
{{1, 3, nil}, {2, 2, nil}, {3, 6, nil}},
|
||||||
{{5, 1}, {6, 7}, {7, 2}},
|
{{5, 1, nil}, {6, 7, nil}, {7, 2, nil}},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -504,24 +504,24 @@ func TestBlockQuerierDelete(t *testing.T) {
|
||||||
ms: []*labels.Matcher{labels.MustNewMatcher(labels.MatchRegexp, "a", ".*")},
|
ms: []*labels.Matcher{labels.MustNewMatcher(labels.MatchRegexp, "a", ".*")},
|
||||||
exp: newMockSeriesSet([]storage.Series{
|
exp: newMockSeriesSet([]storage.Series{
|
||||||
storage.NewListSeries(labels.Labels{{Name: "a", Value: "a"}},
|
storage.NewListSeries(labels.Labels{{Name: "a", Value: "a"}},
|
||||||
[]tsdbutil.Sample{sample{5, 2}, sample{6, 3}, sample{7, 4}},
|
[]tsdbutil.Sample{sample{5, 2, nil}, sample{6, 3, nil}, sample{7, 4, nil}},
|
||||||
),
|
),
|
||||||
storage.NewListSeries(labels.Labels{{Name: "a", Value: "a"}, {Name: "b", Value: "b"}},
|
storage.NewListSeries(labels.Labels{{Name: "a", Value: "a"}, {Name: "b", Value: "b"}},
|
||||||
[]tsdbutil.Sample{sample{5, 3}},
|
[]tsdbutil.Sample{sample{5, 3, nil}},
|
||||||
),
|
),
|
||||||
storage.NewListSeries(labels.Labels{{Name: "b", Value: "b"}},
|
storage.NewListSeries(labels.Labels{{Name: "b", Value: "b"}},
|
||||||
[]tsdbutil.Sample{sample{1, 3}, sample{2, 2}, sample{3, 6}, sample{5, 1}},
|
[]tsdbutil.Sample{sample{1, 3, nil}, sample{2, 2, nil}, sample{3, 6, nil}, sample{5, 1, nil}},
|
||||||
),
|
),
|
||||||
}),
|
}),
|
||||||
expChks: newMockChunkSeriesSet([]storage.ChunkSeries{
|
expChks: newMockChunkSeriesSet([]storage.ChunkSeries{
|
||||||
storage.NewListChunkSeriesFromSamples(labels.Labels{{Name: "a", Value: "a"}},
|
storage.NewListChunkSeriesFromSamples(labels.Labels{{Name: "a", Value: "a"}},
|
||||||
[]tsdbutil.Sample{sample{5, 2}, sample{6, 3}, sample{7, 4}},
|
[]tsdbutil.Sample{sample{5, 2, nil}, sample{6, 3, nil}, sample{7, 4, nil}},
|
||||||
),
|
),
|
||||||
storage.NewListChunkSeriesFromSamples(labels.Labels{{Name: "a", Value: "a"}, {Name: "b", Value: "b"}},
|
storage.NewListChunkSeriesFromSamples(labels.Labels{{Name: "a", Value: "a"}, {Name: "b", Value: "b"}},
|
||||||
[]tsdbutil.Sample{sample{5, 3}},
|
[]tsdbutil.Sample{sample{5, 3, nil}},
|
||||||
),
|
),
|
||||||
storage.NewListChunkSeriesFromSamples(labels.Labels{{Name: "b", Value: "b"}},
|
storage.NewListChunkSeriesFromSamples(labels.Labels{{Name: "b", Value: "b"}},
|
||||||
[]tsdbutil.Sample{sample{1, 3}, sample{2, 2}, sample{3, 6}}, []tsdbutil.Sample{sample{5, 1}},
|
[]tsdbutil.Sample{sample{1, 3, nil}, sample{2, 2, nil}, sample{3, 6, nil}}, []tsdbutil.Sample{sample{5, 1, nil}},
|
||||||
),
|
),
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
|
@ -531,18 +531,18 @@ func TestBlockQuerierDelete(t *testing.T) {
|
||||||
ms: []*labels.Matcher{labels.MustNewMatcher(labels.MatchEqual, "a", "a")},
|
ms: []*labels.Matcher{labels.MustNewMatcher(labels.MatchEqual, "a", "a")},
|
||||||
exp: newMockSeriesSet([]storage.Series{
|
exp: newMockSeriesSet([]storage.Series{
|
||||||
storage.NewListSeries(labels.Labels{{Name: "a", Value: "a"}},
|
storage.NewListSeries(labels.Labels{{Name: "a", Value: "a"}},
|
||||||
[]tsdbutil.Sample{sample{5, 2}, sample{6, 3}},
|
[]tsdbutil.Sample{sample{5, 2, nil}, sample{6, 3, nil}},
|
||||||
),
|
),
|
||||||
storage.NewListSeries(labels.Labels{{Name: "a", Value: "a"}, {Name: "b", Value: "b"}},
|
storage.NewListSeries(labels.Labels{{Name: "a", Value: "a"}, {Name: "b", Value: "b"}},
|
||||||
[]tsdbutil.Sample{sample{5, 3}},
|
[]tsdbutil.Sample{sample{5, 3, nil}},
|
||||||
),
|
),
|
||||||
}),
|
}),
|
||||||
expChks: newMockChunkSeriesSet([]storage.ChunkSeries{
|
expChks: newMockChunkSeriesSet([]storage.ChunkSeries{
|
||||||
storage.NewListChunkSeriesFromSamples(labels.Labels{{Name: "a", Value: "a"}},
|
storage.NewListChunkSeriesFromSamples(labels.Labels{{Name: "a", Value: "a"}},
|
||||||
[]tsdbutil.Sample{sample{5, 2}, sample{6, 3}},
|
[]tsdbutil.Sample{sample{5, 2, nil}, sample{6, 3, nil}},
|
||||||
),
|
),
|
||||||
storage.NewListChunkSeriesFromSamples(labels.Labels{{Name: "a", Value: "a"}, {Name: "b", Value: "b"}},
|
storage.NewListChunkSeriesFromSamples(labels.Labels{{Name: "a", Value: "a"}, {Name: "b", Value: "b"}},
|
||||||
[]tsdbutil.Sample{sample{5, 3}},
|
[]tsdbutil.Sample{sample{5, 3, nil}},
|
||||||
),
|
),
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
|
@ -625,57 +625,57 @@ func TestPopulateWithTombSeriesIterators(t *testing.T) {
|
||||||
{
|
{
|
||||||
name: "one chunk",
|
name: "one chunk",
|
||||||
chks: [][]tsdbutil.Sample{
|
chks: [][]tsdbutil.Sample{
|
||||||
{sample{1, 2}, sample{2, 3}, sample{3, 5}, sample{6, 1}},
|
{sample{1, 2, nil}, sample{2, 3, nil}, sample{3, 5, nil}, sample{6, 1, nil}},
|
||||||
},
|
},
|
||||||
|
|
||||||
expected: []tsdbutil.Sample{
|
expected: []tsdbutil.Sample{
|
||||||
sample{1, 2}, sample{2, 3}, sample{3, 5}, sample{6, 1},
|
sample{1, 2, nil}, sample{2, 3, nil}, sample{3, 5, nil}, sample{6, 1, nil},
|
||||||
},
|
},
|
||||||
expectedChks: []chunks.Meta{
|
expectedChks: []chunks.Meta{
|
||||||
tsdbutil.ChunkFromSamples([]tsdbutil.Sample{
|
tsdbutil.ChunkFromSamples([]tsdbutil.Sample{
|
||||||
sample{1, 2}, sample{2, 3}, sample{3, 5}, sample{6, 1},
|
sample{1, 2, nil}, sample{2, 3, nil}, sample{3, 5, nil}, sample{6, 1, nil},
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "two full chunks",
|
name: "two full chunks",
|
||||||
chks: [][]tsdbutil.Sample{
|
chks: [][]tsdbutil.Sample{
|
||||||
{sample{1, 2}, sample{2, 3}, sample{3, 5}, sample{6, 1}},
|
{sample{1, 2, nil}, sample{2, 3, nil}, sample{3, 5, nil}, sample{6, 1, nil}},
|
||||||
{sample{7, 89}, sample{9, 8}},
|
{sample{7, 89, nil}, sample{9, 8, nil}},
|
||||||
},
|
},
|
||||||
|
|
||||||
expected: []tsdbutil.Sample{
|
expected: []tsdbutil.Sample{
|
||||||
sample{1, 2}, sample{2, 3}, sample{3, 5}, sample{6, 1}, sample{7, 89}, sample{9, 8},
|
sample{1, 2, nil}, sample{2, 3, nil}, sample{3, 5, nil}, sample{6, 1, nil}, sample{7, 89, nil}, sample{9, 8, nil},
|
||||||
},
|
},
|
||||||
expectedChks: []chunks.Meta{
|
expectedChks: []chunks.Meta{
|
||||||
tsdbutil.ChunkFromSamples([]tsdbutil.Sample{
|
tsdbutil.ChunkFromSamples([]tsdbutil.Sample{
|
||||||
sample{1, 2}, sample{2, 3}, sample{3, 5}, sample{6, 1},
|
sample{1, 2, nil}, sample{2, 3, nil}, sample{3, 5, nil}, sample{6, 1, nil},
|
||||||
}),
|
}),
|
||||||
tsdbutil.ChunkFromSamples([]tsdbutil.Sample{
|
tsdbutil.ChunkFromSamples([]tsdbutil.Sample{
|
||||||
sample{7, 89}, sample{9, 8},
|
sample{7, 89, nil}, sample{9, 8, nil},
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "three full chunks",
|
name: "three full chunks",
|
||||||
chks: [][]tsdbutil.Sample{
|
chks: [][]tsdbutil.Sample{
|
||||||
{sample{1, 2}, sample{2, 3}, sample{3, 5}, sample{6, 1}},
|
{sample{1, 2, nil}, sample{2, 3, nil}, sample{3, 5, nil}, sample{6, 1, nil}},
|
||||||
{sample{7, 89}, sample{9, 8}},
|
{sample{7, 89, nil}, sample{9, 8, nil}},
|
||||||
{sample{10, 22}, sample{203, 3493}},
|
{sample{10, 22, nil}, sample{203, 3493, nil}},
|
||||||
},
|
},
|
||||||
|
|
||||||
expected: []tsdbutil.Sample{
|
expected: []tsdbutil.Sample{
|
||||||
sample{1, 2}, sample{2, 3}, sample{3, 5}, sample{6, 1}, sample{7, 89}, sample{9, 8}, sample{10, 22}, sample{203, 3493},
|
sample{1, 2, nil}, sample{2, 3, nil}, sample{3, 5, nil}, sample{6, 1, nil}, sample{7, 89, nil}, sample{9, 8, nil}, sample{10, 22, nil}, sample{203, 3493, nil},
|
||||||
},
|
},
|
||||||
expectedChks: []chunks.Meta{
|
expectedChks: []chunks.Meta{
|
||||||
tsdbutil.ChunkFromSamples([]tsdbutil.Sample{
|
tsdbutil.ChunkFromSamples([]tsdbutil.Sample{
|
||||||
sample{1, 2}, sample{2, 3}, sample{3, 5}, sample{6, 1},
|
sample{1, 2, nil}, sample{2, 3, nil}, sample{3, 5, nil}, sample{6, 1, nil},
|
||||||
}),
|
}),
|
||||||
tsdbutil.ChunkFromSamples([]tsdbutil.Sample{
|
tsdbutil.ChunkFromSamples([]tsdbutil.Sample{
|
||||||
sample{7, 89}, sample{9, 8},
|
sample{7, 89, nil}, sample{9, 8, nil},
|
||||||
}),
|
}),
|
||||||
tsdbutil.ChunkFromSamples([]tsdbutil.Sample{
|
tsdbutil.ChunkFromSamples([]tsdbutil.Sample{
|
||||||
sample{10, 22}, sample{203, 3493},
|
sample{10, 22, nil}, sample{203, 3493, nil},
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -690,8 +690,8 @@ func TestPopulateWithTombSeriesIterators(t *testing.T) {
|
||||||
{
|
{
|
||||||
name: "two chunks and seek beyond chunks",
|
name: "two chunks and seek beyond chunks",
|
||||||
chks: [][]tsdbutil.Sample{
|
chks: [][]tsdbutil.Sample{
|
||||||
{sample{1, 2}, sample{3, 5}, sample{6, 1}},
|
{sample{1, 2, nil}, sample{3, 5, nil}, sample{6, 1, nil}},
|
||||||
{sample{7, 89}, sample{9, 8}},
|
{sample{7, 89, nil}, sample{9, 8, nil}},
|
||||||
},
|
},
|
||||||
seek: 10,
|
seek: 10,
|
||||||
|
|
||||||
|
@ -700,27 +700,27 @@ func TestPopulateWithTombSeriesIterators(t *testing.T) {
|
||||||
{
|
{
|
||||||
name: "two chunks and seek on middle of first chunk",
|
name: "two chunks and seek on middle of first chunk",
|
||||||
chks: [][]tsdbutil.Sample{
|
chks: [][]tsdbutil.Sample{
|
||||||
{sample{1, 2}, sample{3, 5}, sample{6, 1}},
|
{sample{1, 2, nil}, sample{3, 5, nil}, sample{6, 1, nil}},
|
||||||
{sample{7, 89}, sample{9, 8}},
|
{sample{7, 89, nil}, sample{9, 8, nil}},
|
||||||
},
|
},
|
||||||
seek: 2,
|
seek: 2,
|
||||||
|
|
||||||
seekSuccess: true,
|
seekSuccess: true,
|
||||||
expected: []tsdbutil.Sample{
|
expected: []tsdbutil.Sample{
|
||||||
sample{3, 5}, sample{6, 1}, sample{7, 89}, sample{9, 8},
|
sample{3, 5, nil}, sample{6, 1, nil}, sample{7, 89, nil}, sample{9, 8, nil},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "two chunks and seek before first chunk",
|
name: "two chunks and seek before first chunk",
|
||||||
chks: [][]tsdbutil.Sample{
|
chks: [][]tsdbutil.Sample{
|
||||||
{sample{1, 2}, sample{3, 5}, sample{6, 1}},
|
{sample{1, 2, nil}, sample{3, 5, nil}, sample{6, 1, nil}},
|
||||||
{sample{7, 89}, sample{9, 8}},
|
{sample{7, 89, nil}, sample{9, 8, nil}},
|
||||||
},
|
},
|
||||||
seek: -32,
|
seek: -32,
|
||||||
|
|
||||||
seekSuccess: true,
|
seekSuccess: true,
|
||||||
expected: []tsdbutil.Sample{
|
expected: []tsdbutil.Sample{
|
||||||
sample{1, 2}, sample{3, 5}, sample{6, 1}, sample{7, 89}, sample{9, 8},
|
sample{1, 2, nil}, sample{3, 5, nil}, sample{6, 1, nil}, sample{7, 89, nil}, sample{9, 8, nil},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
// Deletion / Trim cases.
|
// Deletion / Trim cases.
|
||||||
|
@ -732,60 +732,60 @@ func TestPopulateWithTombSeriesIterators(t *testing.T) {
|
||||||
{
|
{
|
||||||
name: "two chunks with trimmed first and last samples from edge chunks",
|
name: "two chunks with trimmed first and last samples from edge chunks",
|
||||||
chks: [][]tsdbutil.Sample{
|
chks: [][]tsdbutil.Sample{
|
||||||
{sample{1, 2}, sample{2, 3}, sample{3, 5}, sample{6, 1}},
|
{sample{1, 2, nil}, sample{2, 3, nil}, sample{3, 5, nil}, sample{6, 1, nil}},
|
||||||
{sample{7, 89}, sample{9, 8}},
|
{sample{7, 89, nil}, sample{9, 8, nil}},
|
||||||
},
|
},
|
||||||
intervals: tombstones.Intervals{{Mint: math.MinInt64, Maxt: 2}}.Add(tombstones.Interval{Mint: 9, Maxt: math.MaxInt64}),
|
intervals: tombstones.Intervals{{Mint: math.MinInt64, Maxt: 2}}.Add(tombstones.Interval{Mint: 9, Maxt: math.MaxInt64}),
|
||||||
|
|
||||||
expected: []tsdbutil.Sample{
|
expected: []tsdbutil.Sample{
|
||||||
sample{3, 5}, sample{6, 1}, sample{7, 89},
|
sample{3, 5, nil}, sample{6, 1, nil}, sample{7, 89, nil},
|
||||||
},
|
},
|
||||||
expectedChks: []chunks.Meta{
|
expectedChks: []chunks.Meta{
|
||||||
tsdbutil.ChunkFromSamples([]tsdbutil.Sample{
|
tsdbutil.ChunkFromSamples([]tsdbutil.Sample{
|
||||||
sample{3, 5}, sample{6, 1},
|
sample{3, 5, nil}, sample{6, 1, nil},
|
||||||
}),
|
}),
|
||||||
tsdbutil.ChunkFromSamples([]tsdbutil.Sample{
|
tsdbutil.ChunkFromSamples([]tsdbutil.Sample{
|
||||||
sample{7, 89},
|
sample{7, 89, nil},
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "two chunks with trimmed middle sample of first chunk",
|
name: "two chunks with trimmed middle sample of first chunk",
|
||||||
chks: [][]tsdbutil.Sample{
|
chks: [][]tsdbutil.Sample{
|
||||||
{sample{1, 2}, sample{2, 3}, sample{3, 5}, sample{6, 1}},
|
{sample{1, 2, nil}, sample{2, 3, nil}, sample{3, 5, nil}, sample{6, 1, nil}},
|
||||||
{sample{7, 89}, sample{9, 8}},
|
{sample{7, 89, nil}, sample{9, 8, nil}},
|
||||||
},
|
},
|
||||||
intervals: tombstones.Intervals{{Mint: 2, Maxt: 3}},
|
intervals: tombstones.Intervals{{Mint: 2, Maxt: 3}},
|
||||||
|
|
||||||
expected: []tsdbutil.Sample{
|
expected: []tsdbutil.Sample{
|
||||||
sample{1, 2}, sample{6, 1}, sample{7, 89}, sample{9, 8},
|
sample{1, 2, nil}, sample{6, 1, nil}, sample{7, 89, nil}, sample{9, 8, nil},
|
||||||
},
|
},
|
||||||
expectedChks: []chunks.Meta{
|
expectedChks: []chunks.Meta{
|
||||||
tsdbutil.ChunkFromSamples([]tsdbutil.Sample{
|
tsdbutil.ChunkFromSamples([]tsdbutil.Sample{
|
||||||
sample{1, 2}, sample{6, 1},
|
sample{1, 2, nil}, sample{6, 1, nil},
|
||||||
}),
|
}),
|
||||||
tsdbutil.ChunkFromSamples([]tsdbutil.Sample{
|
tsdbutil.ChunkFromSamples([]tsdbutil.Sample{
|
||||||
sample{7, 89}, sample{9, 8},
|
sample{7, 89, nil}, sample{9, 8, nil},
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "two chunks with deletion across two chunks",
|
name: "two chunks with deletion across two chunks",
|
||||||
chks: [][]tsdbutil.Sample{
|
chks: [][]tsdbutil.Sample{
|
||||||
{sample{1, 2}, sample{2, 3}, sample{3, 5}, sample{6, 1}},
|
{sample{1, 2, nil}, sample{2, 3, nil}, sample{3, 5, nil}, sample{6, 1, nil}},
|
||||||
{sample{7, 89}, sample{9, 8}},
|
{sample{7, 89, nil}, sample{9, 8, nil}},
|
||||||
},
|
},
|
||||||
intervals: tombstones.Intervals{{Mint: 6, Maxt: 7}},
|
intervals: tombstones.Intervals{{Mint: 6, Maxt: 7}},
|
||||||
|
|
||||||
expected: []tsdbutil.Sample{
|
expected: []tsdbutil.Sample{
|
||||||
sample{1, 2}, sample{2, 3}, sample{3, 5}, sample{9, 8},
|
sample{1, 2, nil}, sample{2, 3, nil}, sample{3, 5, nil}, sample{9, 8, nil},
|
||||||
},
|
},
|
||||||
expectedChks: []chunks.Meta{
|
expectedChks: []chunks.Meta{
|
||||||
tsdbutil.ChunkFromSamples([]tsdbutil.Sample{
|
tsdbutil.ChunkFromSamples([]tsdbutil.Sample{
|
||||||
sample{1, 2}, sample{2, 3}, sample{3, 5},
|
sample{1, 2, nil}, sample{2, 3, nil}, sample{3, 5, nil},
|
||||||
}),
|
}),
|
||||||
tsdbutil.ChunkFromSamples([]tsdbutil.Sample{
|
tsdbutil.ChunkFromSamples([]tsdbutil.Sample{
|
||||||
sample{9, 8},
|
sample{9, 8, nil},
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -793,15 +793,15 @@ func TestPopulateWithTombSeriesIterators(t *testing.T) {
|
||||||
{
|
{
|
||||||
name: "two chunks with trimmed first and last samples from edge chunks, seek from middle of first chunk",
|
name: "two chunks with trimmed first and last samples from edge chunks, seek from middle of first chunk",
|
||||||
chks: [][]tsdbutil.Sample{
|
chks: [][]tsdbutil.Sample{
|
||||||
{sample{1, 2}, sample{2, 3}, sample{3, 5}, sample{6, 1}},
|
{sample{1, 2, nil}, sample{2, 3, nil}, sample{3, 5, nil}, sample{6, 1, nil}},
|
||||||
{sample{7, 89}, sample{9, 8}},
|
{sample{7, 89, nil}, sample{9, 8, nil}},
|
||||||
},
|
},
|
||||||
intervals: tombstones.Intervals{{Mint: math.MinInt64, Maxt: 2}}.Add(tombstones.Interval{Mint: 9, Maxt: math.MaxInt64}),
|
intervals: tombstones.Intervals{{Mint: math.MinInt64, Maxt: 2}}.Add(tombstones.Interval{Mint: 9, Maxt: math.MaxInt64}),
|
||||||
|
|
||||||
seek: 3,
|
seek: 3,
|
||||||
seekSuccess: true,
|
seekSuccess: true,
|
||||||
expected: []tsdbutil.Sample{
|
expected: []tsdbutil.Sample{
|
||||||
sample{3, 5}, sample{6, 1}, sample{7, 89},
|
sample{3, 5, nil}, sample{6, 1, nil}, sample{7, 89, nil},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -857,8 +857,8 @@ func rmChunkRefs(chks []chunks.Meta) {
|
||||||
func TestPopulateWithDelSeriesIterator_DoubleSeek(t *testing.T) {
|
func TestPopulateWithDelSeriesIterator_DoubleSeek(t *testing.T) {
|
||||||
f, chkMetas := createFakeReaderAndNotPopulatedChunks(
|
f, chkMetas := createFakeReaderAndNotPopulatedChunks(
|
||||||
[]tsdbutil.Sample{},
|
[]tsdbutil.Sample{},
|
||||||
[]tsdbutil.Sample{sample{1, 1}, sample{2, 2}, sample{3, 3}},
|
[]tsdbutil.Sample{sample{1, 1, nil}, sample{2, 2, nil}, sample{3, 3, nil}},
|
||||||
[]tsdbutil.Sample{sample{4, 4}, sample{5, 5}},
|
[]tsdbutil.Sample{sample{4, 4, nil}, sample{5, 5, nil}},
|
||||||
)
|
)
|
||||||
|
|
||||||
it := newPopulateWithDelGenericSeriesIterator(f, chkMetas, nil).toSeriesIterator()
|
it := newPopulateWithDelGenericSeriesIterator(f, chkMetas, nil).toSeriesIterator()
|
||||||
|
@ -875,7 +875,7 @@ func TestPopulateWithDelSeriesIterator_DoubleSeek(t *testing.T) {
|
||||||
func TestPopulateWithDelSeriesIterator_SeekInCurrentChunk(t *testing.T) {
|
func TestPopulateWithDelSeriesIterator_SeekInCurrentChunk(t *testing.T) {
|
||||||
f, chkMetas := createFakeReaderAndNotPopulatedChunks(
|
f, chkMetas := createFakeReaderAndNotPopulatedChunks(
|
||||||
[]tsdbutil.Sample{},
|
[]tsdbutil.Sample{},
|
||||||
[]tsdbutil.Sample{sample{1, 2}, sample{3, 4}, sample{5, 6}, sample{7, 8}},
|
[]tsdbutil.Sample{sample{1, 2, nil}, sample{3, 4, nil}, sample{5, 6, nil}, sample{7, 8, nil}},
|
||||||
[]tsdbutil.Sample{},
|
[]tsdbutil.Sample{},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -893,7 +893,7 @@ func TestPopulateWithDelSeriesIterator_SeekInCurrentChunk(t *testing.T) {
|
||||||
|
|
||||||
func TestPopulateWithDelSeriesIterator_SeekWithMinTime(t *testing.T) {
|
func TestPopulateWithDelSeriesIterator_SeekWithMinTime(t *testing.T) {
|
||||||
f, chkMetas := createFakeReaderAndNotPopulatedChunks(
|
f, chkMetas := createFakeReaderAndNotPopulatedChunks(
|
||||||
[]tsdbutil.Sample{sample{1, 6}, sample{5, 6}, sample{6, 8}},
|
[]tsdbutil.Sample{sample{1, 6, nil}, sample{5, 6, nil}, sample{6, 8, nil}},
|
||||||
)
|
)
|
||||||
|
|
||||||
it := newPopulateWithDelGenericSeriesIterator(f, chkMetas, nil).toSeriesIterator()
|
it := newPopulateWithDelGenericSeriesIterator(f, chkMetas, nil).toSeriesIterator()
|
||||||
|
@ -905,7 +905,7 @@ func TestPopulateWithDelSeriesIterator_SeekWithMinTime(t *testing.T) {
|
||||||
// Seek gets called and advances beyond the max time, which was just accepted as a valid sample.
|
// Seek gets called and advances beyond the max time, which was just accepted as a valid sample.
|
||||||
func TestPopulateWithDelSeriesIterator_NextWithMinTime(t *testing.T) {
|
func TestPopulateWithDelSeriesIterator_NextWithMinTime(t *testing.T) {
|
||||||
f, chkMetas := createFakeReaderAndNotPopulatedChunks(
|
f, chkMetas := createFakeReaderAndNotPopulatedChunks(
|
||||||
[]tsdbutil.Sample{sample{1, 6}, sample{5, 6}, sample{7, 8}},
|
[]tsdbutil.Sample{sample{1, 6, nil}, sample{5, 6, nil}, sample{7, 8, nil}},
|
||||||
)
|
)
|
||||||
|
|
||||||
it := newPopulateWithDelGenericSeriesIterator(
|
it := newPopulateWithDelGenericSeriesIterator(
|
||||||
|
|
|
@ -74,7 +74,7 @@ type RefExemplar struct {
|
||||||
type RefHistogram struct {
|
type RefHistogram struct {
|
||||||
Ref uint64
|
Ref uint64
|
||||||
T int64
|
T int64
|
||||||
H histogram.Histogram
|
H *histogram.Histogram
|
||||||
}
|
}
|
||||||
|
|
||||||
// Decoder decodes series, sample, and tombstone records.
|
// Decoder decodes series, sample, and tombstone records.
|
||||||
|
@ -253,7 +253,7 @@ func (d *Decoder) Histograms(rec []byte, histograms []RefHistogram) ([]RefHistog
|
||||||
rh := RefHistogram{
|
rh := RefHistogram{
|
||||||
Ref: baseRef + uint64(dref),
|
Ref: baseRef + uint64(dref),
|
||||||
T: baseTime + dtime,
|
T: baseTime + dtime,
|
||||||
H: histogram.Histogram{
|
H: &histogram.Histogram{
|
||||||
Schema: 0,
|
Schema: 0,
|
||||||
ZeroThreshold: 0,
|
ZeroThreshold: 0,
|
||||||
ZeroCount: 0,
|
ZeroCount: 0,
|
||||||
|
|
|
@ -165,9 +165,9 @@ func (it *sampleRingIterator) At() (int64, float64) {
|
||||||
return it.r.at(it.i)
|
return it.r.at(it.i)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (it *sampleRingIterator) AtHistogram() (int64, histogram.Histogram) {
|
func (it *sampleRingIterator) AtHistogram() (int64, *histogram.Histogram) {
|
||||||
// TODO(beorn7): Add proper histogram support.
|
// TODO(beorn7): Add proper histogram support.
|
||||||
return 0, histogram.Histogram{}
|
return 0, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (it *sampleRingIterator) ChunkEncoding() chunkenc.Encoding {
|
func (it *sampleRingIterator) ChunkEncoding() chunkenc.Encoding {
|
||||||
|
|
|
@ -152,12 +152,9 @@ func (it *listSeriesIterator) At() (int64, float64) {
|
||||||
return s.t, s.v
|
return s.t, s.v
|
||||||
}
|
}
|
||||||
|
|
||||||
func (it *listSeriesIterator) AtHistogram() (int64, histogram.Histogram) {
|
func (it *listSeriesIterator) AtHistogram() (int64, *histogram.Histogram) {
|
||||||
s := it.list[it.idx]
|
s := it.list[it.idx]
|
||||||
if s.h == nil {
|
return s.t, s.h
|
||||||
return s.t, histogram.Histogram{}
|
|
||||||
}
|
|
||||||
return s.t, *s.h
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (it *listSeriesIterator) ChunkEncoding() chunkenc.Encoding {
|
func (it *listSeriesIterator) ChunkEncoding() chunkenc.Encoding {
|
||||||
|
|
|
@ -115,7 +115,8 @@ func (h *Handler) federation(w http.ResponseWriter, req *http.Request) {
|
||||||
if ok {
|
if ok {
|
||||||
t, v = it.Values()
|
t, v = it.Values()
|
||||||
} else {
|
} else {
|
||||||
t, v, ok = it.PeekBack(1)
|
// TODO(beorn7): Handle histograms.
|
||||||
|
t, v, _, ok = it.PeekBack(1)
|
||||||
if !ok {
|
if !ok {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
@ -220,6 +221,7 @@ func (h *Handler) federation(w http.ResponseWriter, req *http.Request) {
|
||||||
|
|
||||||
protMetric.TimestampMs = proto.Int64(s.T)
|
protMetric.TimestampMs = proto.Int64(s.T)
|
||||||
protMetric.Untyped.Value = proto.Float64(s.V)
|
protMetric.Untyped.Value = proto.Float64(s.V)
|
||||||
|
// TODO(beorn7): Handle histograms.
|
||||||
|
|
||||||
protMetricFam.Metric = append(protMetricFam.Metric, protMetric)
|
protMetricFam.Metric = append(protMetricFam.Metric, protMetric)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue