Skip to content

GH-55685: [C++][Parquet] Fix DeltaLengthByteArrayEncoder memory pool tracking and zero-length UnsafeAppend - #55686

Open
ryanvickr wants to merge 1 commit into
apache:mainfrom
ryanvickr:gh-55685-dlba-encoder-pool-and-zero-len
Open

ryanvickr wants to merge 1 commit into
apache:mainfrom
ryanvickr:gh-55685-dlba-encoder-pool-and-zero-len

Conversation

@ryanvickr

Copy link
Copy Markdown

Rationale for this change

DeltaLengthByteArrayEncoder currently overwrites the caller's MemoryPool* with default_memory_pool() in its constructor initializer list (affecting both DELTA_LENGTH_BYTE_ARRAY and DELTA_BYTE_ARRAY's suffix_encoder_), and calls BufferBuilder::UnsafeAppend on zero-length ByteArray items (which triggers UB under UBSan when ptr == nullptr).

Split out from #55488 so these fixes can be reviewed separately from the PutBinaryArray optimization.

What changes are included in this PR?

  • Forward pool directly in DeltaLengthByteArrayEncoder's constructor instead of reassigning it to default_memory_pool().
  • Skip sink_.Reserve / sink_.UnsafeAppend for zero-length items in DeltaLengthByteArrayEncoder::Put(const ByteArray*, int).

Are these changes tested?

Yes, added unit tests in cpp/src/parquet/encoding_test.cc for custom memory pool tracking (for both DELTA_LENGTH_BYTE_ARRAY and DELTA_BYTE_ARRAY) and zero-length ByteArray(0, nullptr) inputs.

Are there any user-facing changes?

Callers passing a custom MemoryPool* when encoding DELTA_LENGTH_BYTE_ARRAY or DELTA_BYTE_ARRAY columns will now have encoder allocations tracked on that pool.

Was AI used for this PR?

In accordance to the AI generation guidelines, please disclose below whether and how AI was used in this PR.

PR code and description written by:

  • Human
  • AI

Reviewed before submission by:

  • Human
  • AI
  • Not reviewed

Closes #55685

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[C++][Parquet] Fix DeltaLengthByteArrayEncoder memory pool tracking and zero-length UnsafeAppend

1 participant