Skip to content

Commit

Permalink
enhance: Reserve space of payload writer when serialize data (#33817)
Browse files Browse the repository at this point in the history
See also #33561 #33562

Signed-off-by: Congqi Xia <congqi.xia@zilliz.com>
  • Loading branch information
congqixia committed Jun 17, 2024
1 parent 188ee43 commit f993b29
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions internal/storage/data_codec.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
1 change: 1 addition & 0 deletions internal/storage/payload.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ type PayloadWriterInterface interface {
GetPayloadBufferFromWriter() ([]byte, error)
GetPayloadLengthFromWriter() (int, error)
ReleasePayloadWriter()
Reserve(size int)
Close()
}

Expand Down
4 changes: 4 additions & 0 deletions internal/storage/payload_writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down

0 comments on commit f993b29

Please sign in to comment.