LuciferYang opened a new pull request, #56267:
URL: https://github.com/apache/spark/pull/56267

   ### What changes were proposed in this pull request?
   
   `Ascii` implemented the same first-character logic twice — once in 
`nullSafeEval` and once inlined in `doGenCode` (a ~6-line `substring(0, 1)` / 
`numChars() > 0 ? codePointAt(0) : 0` block). This moves that logic into a 
single `ExpressionImplUtils.ascii(UTF8String): int` helper; `nullSafeEval` 
delegates to it and `doGenCode` becomes a one-line `defineCodeGen` call, so 
eval and codegen share one implementation.
   
   This follows the other SPARK-56908 helpers in `ExpressionImplUtils` and 
lands alongside Crc32 (#56222), regexp (#56223), Chr (#56224), Acosh (#56228), 
and Asinh (#56229), which all append to the same file.
   
   ### Why are the changes needed?
   
   It collapses the inlined block into a single `invokestatic` per `ascii` call 
site — fewer constant-pool entries and a smaller generated method, which helps 
with the JVM 64KB method / constant-pool limits, Janino compile time, and JIT 
work — and removes the duplicated logic between eval and codegen. Part of 
SPARK-56908.
   
   ### Does this PR introduce _any_ user-facing change?
   
   No.
   
   ### How was this patch tested?
   
   Existing `StringExpressionsSuite` `ascii` tests, plus a new assertion for a 
supplementary-plane code point (`ascii('😀') = 128512`) that pins the 
`codePointAt` (rather than `charAt`) behavior. `checkEvaluation` runs both the 
interpreted and codegen paths.
   
   ### Was this patch authored or co-authored using generative AI tooling?
   
   Generated-by: Claude Code (Claude Opus 4.8)
   


-- 
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