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

Method Seek

pkg/querier/batch/chunk.go:31–57  ·  view source on GitHub ↗

Seek advances the iterator forward to the value at or after the given timestamp.

(t int64, size int)

Source from the content-addressed store, hash-verified

29// Seek advances the iterator forward to the value at or after
30// the given timestamp.
31func (i *chunkIterator) Seek(t int64, size int) chunkenc.ValueType {
32 // We assume seeks only care about a specific window; if this chunk doesn't
33 // contain samples in that window, we can shortcut.
34 if i.chunk.MaxTime < t {
35 return chunkenc.ValNone
36 }
37
38 // If the seek is to the middle of the current batch, and size fits, we can
39 // shortcut.
40 if i.batch.Length > 0 && t >= i.batch.Timestamps[0] && t <= i.batch.Timestamps[i.batch.Length-1] {
41 i.batch.Index = 0
42 for i.batch.Index < i.batch.Length && t > i.batch.Timestamps[i.batch.Index] {
43 i.batch.Index++
44 }
45 if i.batch.Index+size < i.batch.Length {
46 return i.batch.ValType
47 }
48 }
49
50 if valueType := i.it.FindAtOrAfter(model.Time(t)); valueType != chunkenc.ValNone {
51 i.batch = i.it.Batch(size, valueType)
52 if i.batch.Length > 0 {
53 return valueType
54 }
55 }
56 return chunkenc.ValNone
57}
58
59func (i *chunkIterator) Next(size int) chunkenc.ValueType {
60 if valueType := i.it.Scan(); valueType != chunkenc.ValNone {

Callers 1

TestSeekFunction · 0.95

Calls 2

FindAtOrAfterMethod · 0.65
BatchMethod · 0.65

Tested by 1

TestSeekFunction · 0.76