tsdb: Remove duplicate variables. (#8239)

Signed-off-by: johncming <johncming@yahoo.com>
This commit is contained in:
johncming 2020-11-30 16:55:33 +08:00 committed by GitHub
parent 759150878c
commit a6e18916ab
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 8 deletions

View File

@ -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