未验证 提交 8b60aa8c 编写于 作者: B Bingyi Sun 提交者: GitHub

Skip single compaction if there's no delta log in a segment (#11806)

Signed-off-by: Nsunby <bingyi.sun@zilliz.com>
Co-authored-by: Nsunby <bingyi.sun@zilliz.com>
上级 f2e720a7
......@@ -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)
})
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册