(tb testing.TB, w *wlog.WL, series []storage.Series, chunkDir string)
| 654 | } |
| 655 | |
| 656 | func createHead(tb testing.TB, w *wlog.WL, series []storage.Series, chunkDir string) *Head { |
| 657 | opts := DefaultHeadOptions() |
| 658 | opts.ChunkDirRoot = chunkDir |
| 659 | head, err := NewHead(nil, nil, w, nil, opts, nil) |
| 660 | require.NoError(tb, err) |
| 661 | |
| 662 | var it chunkenc.Iterator |
| 663 | ctx := context.Background() |
| 664 | app := head.Appender(ctx) |
| 665 | for _, s := range series { |
| 666 | ref := storage.SeriesRef(0) |
| 667 | it = s.Iterator(it) |
| 668 | lset := s.Labels() |
| 669 | typ := it.Next() |
| 670 | lastTyp := typ |
| 671 | for ; typ != chunkenc.ValNone; typ = it.Next() { |
| 672 | if lastTyp != typ { |
| 673 | // The behaviour of appender is undefined if samples of different types |
| 674 | // are appended to the same series in a single Commit(). |
| 675 | require.NoError(tb, app.Commit()) |
| 676 | app = head.Appender(ctx) |
| 677 | } |
| 678 | |
| 679 | switch typ { |
| 680 | case chunkenc.ValFloat: |
| 681 | t, v := it.At() |
| 682 | ref, err = app.Append(ref, lset, t, v) |
| 683 | case chunkenc.ValHistogram: |
| 684 | t, h := it.AtHistogram(nil) |
| 685 | ref, err = app.AppendHistogram(ref, lset, t, h, nil) |
| 686 | case chunkenc.ValFloatHistogram: |
| 687 | t, fh := it.AtFloatHistogram(nil) |
| 688 | ref, err = app.AppendHistogram(ref, lset, t, nil, fh) |
| 689 | default: |
| 690 | err = fmt.Errorf("unknown sample type %s", typ.String()) |
| 691 | } |
| 692 | require.NoError(tb, err) |
| 693 | lastTyp = typ |
| 694 | } |
| 695 | require.NoError(tb, it.Err()) |
| 696 | } |
| 697 | require.NoError(tb, app.Commit()) |
| 698 | return head |
| 699 | } |
| 700 | |
| 701 | func createHeadWithOOOSamples(tb testing.TB, w *wlog.WL, series []storage.Series, chunkDir string, oooSampleFrequency int) *Head { |
| 702 | opts := DefaultHeadOptions() |
no test coverage detected
searching dependent graphs…