ChaomingZhangCN opened a new pull request, #29141:
URL: https://github.com/apache/flink/pull/29141

   ## What is the purpose of the change
   
   Fix code splitting for large `if` blocks containing nested loops with 
`break` or `continue`.
   
   Currently, `BlockStatementSplitter` skips a statement whenever its subtree 
contains any `return`, `break`, or `continue`. This is overly conservative for 
an enclosing block containing a self-contained loop: even a small loop with a 
jump can prevent the surrounding large block from being split, leaving 
generated methods that fail compilation with `Code grows beyond 64 KB`.
   
   This change allows such enclosing blocks to be split while retaining 
conservative guards for return statements and loop-body extraction.
   
   ## Brief change log
   
   - Track return statements separately from the combined return/jump count.
   - Allow enclosing blocks containing self-contained loops with jumps to be 
extracted.
   - Preserve the restrictions on extracting blocks containing returns and loop 
bodies containing jumps.
   - Add rewrite fixtures and compilation/execution regression tests covering 
oversized branches, `break`, `continue`, labeled jumps, and early returns.
   
   ## Verifying this change
   
   Added regression tests that generate an oversized `if` branch containing a 
short loop with either `break` or `continue`, run the complete 
`JavaCodeSplitter` pipeline, compile the output with Janino, and verify 
execution results.
   
   Both oversized-branch test cases fail on the unmodified base commit with 
`Code grows beyond 64 KB` and pass with this change. The tests also verify that 
skipped branches remain unexecuted and that statements following a jump execute 
correctly.
   
   Additional execution tests verify labeled `break`/`continue` and 
early-return behavior.
   
   The complete code-splitter module test suite was run with its reactor 
dependencies using JDK 17 and the repository's Maven wrapper:
   
   ```bash
   ./mvnw -pl flink-table/flink-table-code-splitter -am \
     -Drat.skip=true \
     '-Dtest=org.apache.flink.table.codesplit.*Test' \
     -Dsurefire.failIfNoSpecifiedTests=false \
     test
   ```
   
   Result: 54 tests, 0 failures, 0 errors, and 1 pre-existing skipped test.
   
   Spotless and Checkstyle checks also passed. The reactor command skips the 
repository-wide RAT scan; a module-scoped RAT check was run separately and 
passed. The full repository test suite was not run.
   
   ## Does this pull request potentially affect one of the following parts:
   
   - Dependencies: no.
   - Public API: no.
   - Serializers: no.
   - Runtime per-record code paths: yes, generated code may be split into 
additional helper methods; no hand-written runtime operator changes.
   - Deployment or recovery infrastructure: no.
   - S3 file system connector: no.
   
   ## Documentation
   
   - Does this pull request introduce a new feature? No, this is a 
code-splitting bug fix.
   - How is the feature documented? Not applicable.
   
   ---
   
   ##### Was generative AI tooling used to co-author this PR?
   
   - [X] Yes.
   
   Generated-by: Codex CLI 0.153.4


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

Reply via email to