(t int64, size int)
| 85 | } |
| 86 | |
| 87 | func (c *mergeIterator) Seek(t int64, size int) chunkenc.ValueType { |
| 88 | |
| 89 | // Optimisation to see if the seek is within our current caches batches. |
| 90 | found: |
| 91 | for len(c.batches) > 0 { |
| 92 | batch := &c.batches[0] |
| 93 | if t >= batch.Timestamps[0] && t <= batch.Timestamps[batch.Length-1] { |
| 94 | batch.Index = 0 |
| 95 | for batch.Index < batch.Length && t > batch.Timestamps[batch.Index] { |
| 96 | batch.Index++ |
| 97 | } |
| 98 | break found |
| 99 | } |
| 100 | copy(c.batches, c.batches[1:]) |
| 101 | c.batches = c.batches[:len(c.batches)-1] |
| 102 | } |
| 103 | |
| 104 | // If we didn't find anything in the current set of batches, reset the heap |
| 105 | // and seek. |
| 106 | if len(c.batches) == 0 { |
| 107 | c.h = c.h[:0] |
| 108 | c.batches = c.batches[:0] |
| 109 | |
| 110 | for _, iter := range c.its { |
| 111 | if iter.Seek(t, size) != chunkenc.ValNone { |
| 112 | c.h = append(c.h, iter) |
| 113 | continue |
| 114 | } |
| 115 | |
| 116 | if err := iter.Err(); err != nil { |
| 117 | c.currErr = err |
| 118 | return chunkenc.ValNone |
| 119 | } |
| 120 | } |
| 121 | |
| 122 | heap.Init(&c.h) |
| 123 | } |
| 124 | |
| 125 | return c.buildNextBatch(size) |
| 126 | } |
| 127 | |
| 128 | func (c *mergeIterator) Next(size int) chunkenc.ValueType { |
| 129 | // Pop the last built batch in a way that doesn't extend the slice. |
nothing calls this directly
no test coverage detected