Repository navigation
Conversation
| size_ += length; | ||
| } | ||
|
|
||
| void UnsafeAppend(std::string_view v) { |
There was a problem hiding this comment.
I suggest to modify this method instead.
There was a problem hiding this comment.
Fixing here can cover direct calls to that overload. Append(std::string_view{}) goes through Append(const void*, int64_t) and calls UnsafeAppend(const void*, int64_t) directly. Parquet ByteArray encoders also call the pointer-and-length overload directly, including for zero-length payloads.
|
I ran the Parquet write benchmarks on an Apple M5 Pro with Apple Clang 21. Parquet PLAIN byte-array encoding.
Before this PR After this PR Parquet DELTA_LENGTH_BYTE_ARRAY encoding.
Before this PR After this PR Parquet DELTA_BYTE_ARRAY encoding.
Before this PR After this PR Parquet binary column writer (high cardinality, PLAIN fallback).
Before this PR After this PR |
| @@ -155,8 +155,11 @@ | |||
|
|
|||
| // Unsafe methods don't check existing size | |||
There was a problem hiding this comment.
Or we should add comment for UnsafeAppend, which == 0 is unsafe in this scenario? ( I'm open to these scenario )
|
What do you think? I'm inclined to add such fix but also worried about its regression. @pitrou |
Rationale for this change
Appending a default
std::string_viewto aBufferBuilderis UB because it can pass the null pointer tomemcpy.What changes are included in this PR?
BufferBuilder::UnsafeAppendnow returns immediately when the length is zero. BothAppendandUnsafeAppenduse this path.Are these changes tested?
Extended
TestBufferBuilder.FinishEmptyto cover appending an empty view before and after reserving capacity.Are there any user-facing changes?
No.
Was AI used for this PR?
PR code and description written by:
Reviewed before submission by: