Skip to content

Commit

Permalink
enhance: Preallocate delete data slice to avoid growslice
Browse files Browse the repository at this point in the history
Related to milvus-io#36887

Signed-off-by: Congqi Xia <[email protected]>
  • Loading branch information
congqixia committed Oct 22, 2024
1 parent 50607a5 commit b0883f1
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions internal/querynodev2/segments/segment_loader.go
Original file line number Diff line number Diff line change
Expand Up @@ -1183,8 +1183,9 @@ func (loader *segmentLoader) LoadDeltaLogs(ctx context.Context, segment Segment,
return nil, err
}
blob := &storage.Blob{
Key: bLog.GetLogPath(),
Value: value,
Key: bLog.GetLogPath(),
Value: value,
RowNum: bLog.EntriesNum,
}
return blob, nil
})
Expand All @@ -1203,7 +1204,14 @@ func (loader *segmentLoader) LoadDeltaLogs(ctx context.Context, segment Segment,
return nil
}

deltaData := &storage.DeleteData{}
rowNums := lo.SumBy(blobs, func(blob *storage.Blob) int64 {
return blob.RowNum
})
deltaData := &storage.DeleteData{
Pks: make([]storage.PrimaryKey, 0, rowNums),
Tss: make([]uint64, 0, rowNums),
}

reader, err := storage.CreateDeltalogReader(blobs)
if err != nil {
return err
Expand Down

0 comments on commit b0883f1

Please sign in to comment.