Seek advances the iterator forward to the value at or after the given timestamp.
(t int64, size int)
| 29 | // Seek advances the iterator forward to the value at or after |
| 30 | // the given timestamp. |
| 31 | func (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 | |
| 59 | func (i *chunkIterator) Next(size int) chunkenc.ValueType { |
| 60 | if valueType := i.it.Scan(); valueType != chunkenc.ValNone { |