enhance: Preallocate delete data slice to avoid growslice (#37043)

Related to #36887

Signed-off-by: Congqi Xia <congqi.xia@zilliz.com>
This commit is contained in:
congqixia 2024-10-22 19:07:29 +08:00 committed by GitHub
parent 0d8f20f7ce
commit 5dd3f44cc1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

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