fix the refs logic for the addFast path for createBlock (#504)

Signed-off-by: Krasi Georgiev <kgeorgie@redhat.com>
This commit is contained in:
Krasi Georgiev 2019-01-21 14:56:26 +03:00 committed by GitHub
parent 10ba228e6b
commit cc277e398b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -68,17 +68,20 @@ func createBlock(tb testing.TB, dir string, nSeries int, mint, maxt int64) strin
lbls, err := labels.ReadLabels(filepath.Join("testdata", "20kseries.json"), nSeries) lbls, err := labels.ReadLabels(filepath.Join("testdata", "20kseries.json"), nSeries)
testutil.Ok(tb, err) testutil.Ok(tb, err)
var ref uint64 refs := make([]uint64, nSeries)
for ts := mint; ts <= maxt; ts++ { for ts := mint; ts <= maxt; ts++ {
app := head.Appender() app := head.Appender()
for _, lbl := range lbls { for i, lbl := range lbls {
err := app.AddFast(ref, ts, rand.Float64()) if refs[i] != 0 {
if err == nil { err := app.AddFast(refs[i], ts, rand.Float64())
continue if err == nil {
continue
}
} }
ref, err = app.Add(lbl, int64(ts), rand.Float64()) ref, err := app.Add(lbl, int64(ts), rand.Float64())
testutil.Ok(tb, err) testutil.Ok(tb, err)
refs[i] = ref
} }
err := app.Commit() err := app.Commit()
testutil.Ok(tb, err) testutil.Ok(tb, err)