mirror of https://github.com/milvus-io/milvus.git
Skip single compaction if there's no delta log in a segment (#11806)
Signed-off-by: sunby <bingyi.sun@zilliz.com> Co-authored-by: sunby <bingyi.sun@zilliz.com>pull/11876/head
parent
f2e720a77c
commit
8b60aa8c4e
|
@ -23,13 +23,17 @@ func (f singleCompactionFunc) generatePlan(segment *SegmentInfo, timetravel *tim
|
|||
}
|
||||
|
||||
func chooseAllBinlogs(segment *SegmentInfo, timetravel *timetravel) *datapb.CompactionPlan {
|
||||
deltaLogs := make([]*datapb.DeltaLogInfo, 0)
|
||||
var deltaLogs []*datapb.DeltaLogInfo
|
||||
for _, l := range segment.GetDeltalogs() {
|
||||
if l.TimestampTo < timetravel.time {
|
||||
deltaLogs = append(deltaLogs, l)
|
||||
}
|
||||
}
|
||||
|
||||
if len(deltaLogs) == 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
return &datapb.CompactionPlan{
|
||||
SegmentBinlogs: []*datapb.CompactionSegmentBinlogs{
|
||||
{
|
||||
|
|
|
@ -108,3 +108,34 @@ func Test_greedyMergeCompaction(t *testing.T) {
|
|||
})
|
||||
}
|
||||
}
|
||||
|
||||
func Test_chooseAllBinlogs(t *testing.T) {
|
||||
type args struct {
|
||||
segment *SegmentInfo
|
||||
timetravel *timetravel
|
||||
}
|
||||
tests := []struct {
|
||||
name string
|
||||
args args
|
||||
want *datapb.CompactionPlan
|
||||
}{
|
||||
{
|
||||
"test no delta logs",
|
||||
args{
|
||||
segment: &SegmentInfo{
|
||||
SegmentInfo: &datapb.SegmentInfo{
|
||||
ID: 1,
|
||||
Deltalogs: nil,
|
||||
},
|
||||
},
|
||||
},
|
||||
nil,
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
got := chooseAllBinlogs(tt.args.segment, tt.args.timetravel)
|
||||
assert.EqualValues(t, tt.want, got)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue