MCPcopy Create free account
hub / github.com/cortexproject/cortex / partitionChunks

Function partitionChunks

pkg/querier/batch/merge.go:208–226  ·  view source on GitHub ↗

Build a list of lists of non-overlapping chunks.

(cs []GenericChunk)

Source from the content-addressed store, hash-verified

206
207// Build a list of lists of non-overlapping chunks.
208func partitionChunks(cs []GenericChunk) [][]GenericChunk {
209 sort.Sort(byMinTime(cs))
210
211 css := [][]GenericChunk{}
212outer:
213 for _, c := range cs {
214 for i, cs := range css {
215 if cs[len(cs)-1].MaxTime < c.MinTime {
216 css[i] = append(css[i], c)
217 continue outer
218 }
219 }
220 cs := make([]GenericChunk, 0, len(cs)/(len(css)+1))
221 cs = append(cs, c)
222 css = append(css, cs)
223 }
224
225 return css
226}
227
228type byMinTime []GenericChunk
229

Callers 1

newMergeIteratorFunction · 0.85

Calls 1

byMinTimeTypeAlias · 0.85

Tested by

no test coverage detected