Skip to content

Commit

Permalink
Fixes for zero index missing error in log deduplication
Browse files Browse the repository at this point in the history
  • Loading branch information
nocturnalastro committed Feb 7, 2024
1 parent 2711c72 commit 3a41df9
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions pkg/loglines/lines.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,10 @@ func (lt *GenerationalLockedTime) Generation() uint32 {
func (lt *GenerationalLockedTime) Update(update time.Time) {
lt.lock.Lock()
defer lt.lock.Unlock()
lt.time = update
lt.generation += 1
if update.After(lt.time) {
lt.time = update
lt.generation += 1
}
}

type LineSlice struct {
Expand Down Expand Up @@ -221,6 +223,9 @@ func (gens *Generations) FlushAll() *LineSlice {
for _, value := range gens.Store {
gensToFlush = append(gensToFlush, value)
}
if len(gensToFlush) == 0 {
return &LineSlice{}
}
result, lastSlice := gens.flush(gensToFlush)
return MakeSliceFromLines(MakeNewCombinedSlice(result.Lines, lastSlice.Lines), lastSlice.Generation)
}
Expand All @@ -239,6 +244,9 @@ func (gens *Generations) flush(generations [][]*LineSlice) (*LineSlice, *LineSli
}

func MakeSliceFromLines(lines []*ProcessedLine, generation uint32) *LineSlice {
if len(lines) == 0 {
return &LineSlice{Generation: generation}
}
return &LineSlice{
Lines: lines,
start: lines[0].Timestamp,
Expand Down

0 comments on commit 3a41df9

Please sign in to comment.