kazantsev-maksim opened a new pull request, #23909:
URL: https://github.com/apache/datafusion/pull/23909

   ## Which issue does this PR close?
   
   N/A
   
   ## Rationale for this change
   
   Optimize existing expression.
   
   ## What changes are included in this PR?
   
   - Replaced dynamic string building with a fixed-size stack array [b'0'; 4] 
initialized with zeros. The code is filled in place and converted instantly 
using `unsafe { std::str::from_utf8_unchecked(&buf).to_string() }`, resulting 
in zero heap allocations for code formatting.
   - Added an ASCII Fast-Path (s.is_ascii()). When inputs consist entirely of 
ASCII characters, the function operates directly on raw UTF-8 byte slices 
(&[u8]) with optimized byte classification (classify_byte), falling back to the 
Unicode char path only for non-ASCII text.
   - Replaced .collect() with GenericStringBuilder::<O>::with_capacity(rows, 
rows * 4) and StringBuilder::with_capacity for Utf8View. Since every Soundex 
result is guaranteed to be exactly 4 bytes, memory for the entire output column 
is pre-allocated in a single block, eliminating column-level heap 
re-allocations entirely.
   
   ## Are these changes tested?
   
   Existing tests.
   
   Benchmark (criterion):
   
   <img width="627" height="150" alt="image" 
src="https://github.com/user-attachments/assets/609e7fdd-f1c8-45cd-bffc-adff0c331b06";
 />
   
   ## 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