Merge pull request #3959 from prometheus/22-pick-ring
Cherrypick #3942 onto release 2.2
This commit is contained in:
commit
0847a605a7
|
@ -178,6 +178,7 @@ func (r *sampleRing) add(t int64, v float64) {
|
||||||
r.buf = buf
|
r.buf = buf
|
||||||
r.i = r.f
|
r.i = r.f
|
||||||
r.f += l
|
r.f += l
|
||||||
|
l = 2 * l
|
||||||
} else {
|
} else {
|
||||||
r.i++
|
r.i++
|
||||||
if r.i >= l {
|
if r.i >= l {
|
||||||
|
|
|
@ -48,6 +48,11 @@ func TestSampleRing(t *testing.T) {
|
||||||
delta: 7,
|
delta: 7,
|
||||||
size: 1,
|
size: 1,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
input: []int64{1, 2, 3, 4, 6},
|
||||||
|
delta: 4,
|
||||||
|
size: 4,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
for _, c := range cases {
|
for _, c := range cases {
|
||||||
r := newSampleRing(c.delta, c.size)
|
r := newSampleRing(c.delta, c.size)
|
||||||
|
|
Loading…
Reference in New Issue