Index: labels -> postings -> chunkMetas -> chunkRef. ChunkReader: ref -> vals.
(t *testing.T, tc []seriesSamples)
| 106 | // Index: labels -> postings -> chunkMetas -> chunkRef. |
| 107 | // ChunkReader: ref -> vals. |
| 108 | func createIdxChkReaders(t *testing.T, tc []seriesSamples) (IndexReader, ChunkReader, int64, int64) { |
| 109 | sort.Slice(tc, func(i, _ int) bool { |
| 110 | return labels.Compare(labels.FromMap(tc[i].lset), labels.FromMap(tc[i].lset)) < 0 |
| 111 | }) |
| 112 | |
| 113 | postings := index.NewMemPostings() |
| 114 | chkReader := mockChunkReader(make(map[chunks.ChunkRef]chunkenc.Chunk)) |
| 115 | lblIdx := make(map[string]map[string]struct{}) |
| 116 | mi := newMockIndex() |
| 117 | blockMint := int64(math.MaxInt64) |
| 118 | blockMaxt := int64(math.MinInt64) |
| 119 | |
| 120 | var chunkRef chunks.ChunkRef |
| 121 | for i, s := range tc { |
| 122 | i++ // 0 is not a valid posting. |
| 123 | metas := make([]chunks.Meta, 0, len(s.chunks)) |
| 124 | for _, chk := range s.chunks { |
| 125 | if chk[0].t < blockMint { |
| 126 | blockMint = chk[0].t |
| 127 | } |
| 128 | if chk[len(chk)-1].t > blockMaxt { |
| 129 | blockMaxt = chk[len(chk)-1].t |
| 130 | } |
| 131 | |
| 132 | metas = append(metas, chunks.Meta{ |
| 133 | MinTime: chk[0].t, |
| 134 | MaxTime: chk[len(chk)-1].t, |
| 135 | Ref: chunkRef, |
| 136 | }) |
| 137 | |
| 138 | switch { |
| 139 | case chk[0].fh != nil: |
| 140 | chunk := chunkenc.NewFloatHistogramChunk() |
| 141 | app, _ := chunk.Appender() |
| 142 | for _, smpl := range chk { |
| 143 | require.NotNil(t, smpl.fh, "chunk can only contain one type of sample") |
| 144 | _, _, _, err := app.AppendFloatHistogram(nil, 0, smpl.t, smpl.fh, true) |
| 145 | require.NoError(t, err, "chunk should be appendable") |
| 146 | } |
| 147 | chkReader[chunkRef] = chunk |
| 148 | case chk[0].h != nil: |
| 149 | chunk := chunkenc.NewHistogramChunk() |
| 150 | app, _ := chunk.Appender() |
| 151 | for _, smpl := range chk { |
| 152 | require.NotNil(t, smpl.h, "chunk can only contain one type of sample") |
| 153 | _, _, _, err := app.AppendHistogram(nil, 0, smpl.t, smpl.h, true) |
| 154 | require.NoError(t, err, "chunk should be appendable") |
| 155 | } |
| 156 | chkReader[chunkRef] = chunk |
| 157 | default: |
| 158 | chunk := chunkenc.NewXORChunk() |
| 159 | app, _ := chunk.Appender() |
| 160 | for _, smpl := range chk { |
| 161 | require.Nil(t, smpl.h, "chunk can only contain one type of sample") |
| 162 | require.Nil(t, smpl.fh, "chunk can only contain one type of sample") |
| 163 | app.Append(0, smpl.t, smpl.f) |
| 164 | } |
| 165 | chkReader[chunkRef] = chunk |
no test coverage detected
searching dependent graphs…