tsdb: Remove duplicate variables. (#8239)
Signed-off-by: johncming <johncming@yahoo.com>
This commit is contained in:
parent
759150878c
commit
a6e18916ab
15
tsdb/head.go
15
tsdb/head.go
|
@ -2115,26 +2115,25 @@ func (s *memSeries) chunkID(pos int) int {
|
||||||
// have no timestamp at or after mint.
|
// have no timestamp at or after mint.
|
||||||
// Chunk IDs remain unchanged.
|
// Chunk IDs remain unchanged.
|
||||||
func (s *memSeries) truncateChunksBefore(mint int64) (removed int) {
|
func (s *memSeries) truncateChunksBefore(mint int64) (removed int) {
|
||||||
var k int
|
|
||||||
if s.headChunk != nil && s.headChunk.maxTime < mint {
|
if s.headChunk != nil && s.headChunk.maxTime < mint {
|
||||||
// If head chunk is truncated, we can truncate all mmapped chunks.
|
// If head chunk is truncated, we can truncate all mmapped chunks.
|
||||||
k = 1 + len(s.mmappedChunks)
|
removed = 1 + len(s.mmappedChunks)
|
||||||
s.firstChunkID += k
|
s.firstChunkID += removed
|
||||||
s.headChunk = nil
|
s.headChunk = nil
|
||||||
s.mmappedChunks = nil
|
s.mmappedChunks = nil
|
||||||
return k
|
return removed
|
||||||
}
|
}
|
||||||
if len(s.mmappedChunks) > 0 {
|
if len(s.mmappedChunks) > 0 {
|
||||||
for i, c := range s.mmappedChunks {
|
for i, c := range s.mmappedChunks {
|
||||||
if c.maxTime >= mint {
|
if c.maxTime >= mint {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
k = i + 1
|
removed = i + 1
|
||||||
}
|
}
|
||||||
s.mmappedChunks = append(s.mmappedChunks[:0], s.mmappedChunks[k:]...)
|
s.mmappedChunks = append(s.mmappedChunks[:0], s.mmappedChunks[removed:]...)
|
||||||
s.firstChunkID += k
|
s.firstChunkID += removed
|
||||||
}
|
}
|
||||||
return k
|
return removed
|
||||||
}
|
}
|
||||||
|
|
||||||
// append adds the sample (t, v) to the series. The caller also has to provide
|
// append adds the sample (t, v) to the series. The caller also has to provide
|
||||||
|
|
Loading…
Reference in New Issue