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

   ### What changes were proposed in this pull request?
   
   Add `ArrayExpressionUtils.sliceStartIndex(int start, int numElements, String 
functionName)` and `ArrayExpressionUtils.sliceLength(int length, int 
numElements, int startIdx, String functionName)`, and route `Slice`'s codegen 
through them.
   
   `Slice.doGenCode` previously emitted ~17 lines of inline, 
element-type-independent index arithmetic (1-based -> 0-based start resolution, 
the `start == 0` / `length < 0` validations, and the result-length clamp). It 
now emits two helper calls. The eval path reuses `sliceStartIndex` for the 
shared start resolution.
   
   Unlike the earlier SPARK-56908 sub-tasks, this is neither ANSI-specific nor 
a try/catch wrapper -- it is a plain, type-independent block of generated 
logic, which is exactly the kind of boilerplate the umbrella aims to 
deduplicate into static Java helpers.
   
   ### Why are the changes needed?
   
   Part of SPARK-56908 (umbrella). Moving the fixed index arithmetic out of the 
generated Java shrinks the per-stage source for every plan that uses `slice`, 
helping with the JVM 64KB method / constant-pool limits, Janino compile time, 
and JIT work.
   
   ### Does this PR introduce _any_ user-facing change?
   
   No. The compiled behavior is identical; only the emitted Java source text 
changes. The codegen path keeps its existing result-length clamp 
(`sliceLength`); the eval path keeps its existing `data.slice(...)` length 
handling unchanged.
   
   ### How was this patch tested?
   
   ```
   build/sbt "catalyst/testOnly *CollectionExpressionsSuite"
   ```
   
   59/59 pass, including `Slice` (exercised both with and without whole-stage 
codegen).
   
   ### Was this patch authored or co-authored using generative AI tooling?
   
   Generated-by: Claude Code (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