mirror of
https://github.com/prometheus/prometheus.git
synced 2024-12-28 15:09:39 -08:00
Merge pull request #10105 from prometheus/beorn7/histogram2
sparsehistogram: Address two TODOs
This commit is contained in:
commit
927557dc5d
|
@ -470,7 +470,10 @@ type FloatBucket struct {
|
||||||
Lower, Upper float64
|
Lower, Upper float64
|
||||||
LowerInclusive, UpperInclusive bool
|
LowerInclusive, UpperInclusive bool
|
||||||
Count float64
|
Count float64
|
||||||
Index int32 // Index within schema. To easily compare buckets that share the same schema.
|
|
||||||
|
// Index within schema. To easily compare buckets that share the same
|
||||||
|
// schema and sign (positive or negative). Irrelevant for the zero bucket.
|
||||||
|
Index int32
|
||||||
}
|
}
|
||||||
|
|
||||||
// String returns a string representation of a FloatBucket, using the usual
|
// String returns a string representation of a FloatBucket, using the usual
|
||||||
|
@ -686,7 +689,7 @@ func (r *allFloatBucketIterator) Next() bool {
|
||||||
LowerInclusive: true,
|
LowerInclusive: true,
|
||||||
UpperInclusive: true,
|
UpperInclusive: true,
|
||||||
Count: r.h.ZeroCount,
|
Count: r.h.ZeroCount,
|
||||||
Index: math.MinInt32, // TODO(codesome): What is the index for this?
|
// Index is irrelevant for the zero bucket.
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,6 @@ package histogram
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"math"
|
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
|
@ -973,7 +972,6 @@ func TestAllFloatBucketIterator(t *testing.T) {
|
||||||
LowerInclusive: true,
|
LowerInclusive: true,
|
||||||
UpperInclusive: true,
|
UpperInclusive: true,
|
||||||
Count: c.h.ZeroCount,
|
Count: c.h.ZeroCount,
|
||||||
Index: math.MinInt32,
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
if c.includePos {
|
if c.includePos {
|
||||||
|
|
|
@ -3002,8 +3002,8 @@ func TestSparseHistogram_Sum_AddOperator(t *testing.T) {
|
||||||
ts := int64(i+1) * int64(10*time.Minute/time.Millisecond)
|
ts := int64(i+1) * int64(10*time.Minute/time.Millisecond)
|
||||||
app := test.Storage().Appender(context.TODO())
|
app := test.Storage().Appender(context.TODO())
|
||||||
for idx, h := range c.histograms {
|
for idx, h := range c.histograms {
|
||||||
// TODO(codesome): Without h.Copy(), it was working weird. TSDB is keeping reference of last histogram. AppendHistogram should not take pointers!
|
|
||||||
lbls := labels.FromStrings("__name__", seriesName, "idx", fmt.Sprintf("%d", idx))
|
lbls := labels.FromStrings("__name__", seriesName, "idx", fmt.Sprintf("%d", idx))
|
||||||
|
// Since we mutate h later, we need to create a copy here.
|
||||||
_, err = app.AppendHistogram(0, lbls, ts, h.Copy())
|
_, err = app.AppendHistogram(0, lbls, ts, h.Copy())
|
||||||
}
|
}
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
|
@ -234,7 +234,11 @@ type HistogramAppender interface {
|
||||||
// histograms in the same or later transactions. Returned reference
|
// histograms in the same or later transactions. Returned reference
|
||||||
// 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.
|
||||||
|
//
|
||||||
|
// For efficiency reasons, the histogram is passed as a
|
||||||
|
// pointer. AppendHistogram won't mutate the histogram, but in turn
|
||||||
|
// depends on the caller to not mutate it either.
|
||||||
AppendHistogram(ref SeriesRef, l labels.Labels, t int64, h *histogram.Histogram) (SeriesRef, error)
|
AppendHistogram(ref SeriesRef, l labels.Labels, t int64, h *histogram.Histogram) (SeriesRef, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue