diff --git a/internal/storage/data_codec.go b/internal/storage/data_codec.go index 59f2b89ad4..e578c3ec53 100644 --- a/internal/storage/data_codec.go +++ b/internal/storage/data_codec.go @@ -290,6 +290,7 @@ func (insertCodec *InsertCodec) Serialize(partitionID UniqueID, segmentID Unique return nil, err } eventWriter.SetEventTimestamp(startTs, endTs) + eventWriter.Reserve(int(rowNum)) var memorySize int64 for _, block := range data { diff --git a/internal/storage/payload.go b/internal/storage/payload.go index 99fa0f5209..683b91b401 100644 --- a/internal/storage/payload.go +++ b/internal/storage/payload.go @@ -47,6 +47,7 @@ type PayloadWriterInterface interface { GetPayloadBufferFromWriter() ([]byte, error) GetPayloadLengthFromWriter() (int, error) ReleasePayloadWriter() + Reserve(size int) Close() } diff --git a/internal/storage/payload_writer.go b/internal/storage/payload_writer.go index 819b20b1b4..b8b3c68f23 100644 --- a/internal/storage/payload_writer.go +++ b/internal/storage/payload_writer.go @@ -535,6 +535,10 @@ func (w *NativePayloadWriter) FinishPayloadWriter() error { ) } +func (w *NativePayloadWriter) Reserve(size int) { + w.builder.Reserve(size) +} + func (w *NativePayloadWriter) GetPayloadBufferFromWriter() ([]byte, error) { data := w.output.Bytes()