andygrove opened a new pull request, #23473:
URL: https://github.com/apache/datafusion/pull/23473

   ## Which issue does this PR close?
   
   N/A
   
   ## Rationale for this change
   
   The Spark `hex` function's byte-encoding path (`hex_encode_bytes`) filled a 
reusable per-row `Vec` and then copied it into a `StringBuilder` for every row. 
Since each input byte maps to exactly two hex characters, the output can be 
written once directly into a single value buffer, eliminating the per-row copy.
   
   ## What changes are included in this PR?
   
   Rewrote `hex_encode_bytes` to write hex digits directly into one growing 
value buffer with manually-tracked offsets and a `NullBufferBuilder`, 
constructing the `StringArray` via `new_unchecked` (the buffer contains only 
ASCII hex digits, so the existing no-validation behavior is preserved). The 
256-entry lookup table and all other hex paths are unchanged.
   
   ## Are these changes tested?
   
   Existing tests (`function::math::hex`) pass unchanged.
   
   Benchmark (`datafusion/spark/benches/hex.rs`):
   
   - hex_binary/1024·4096·8192: ~13.8% / 14.3% / 13.9% faster
   - hex_utf8/1024·4096·8192: ~14.1% / 14.9% / 15.0% faster
   
   ## Are there any user-facing changes?
   
   No
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to