Skip to content

[FEA] Add Java bindings for multi-output AST JIT - #23828

Open
thirtiseven wants to merge 2 commits into
NVIDIA:mainfrom
thirtiseven:ast-jit-multi-output-literal-jni
Open

[FEA] Add Java bindings for multi-output AST JIT#23828
thirtiseven wants to merge 2 commits into
NVIDIA:mainfrom
thirtiseven:ast-jit-multi-output-literal-jni

Conversation

@thirtiseven

@thirtiseven thirtiseven commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

Description

This PR exposes the libcudf AST JIT capabilities introduced by #23615 and #23621 through the Java API.

The execution backend is selected when an expression is compiled:

  • AstExpression.compile() preserves the existing behavior and produces an expression compatible with default AST consumers.
  • AstExpression.compileJit() produces a JIT-specific expression. Each CompiledExpression owns only the native AST tree and literal representation required by its compilation mode.
  • CompiledExpression.computeColumn(Table) executes using the compiled expression's mode, avoiding a separate computeColumnJit API and avoiding duplicate native AST trees.
  • CompiledExpression.computeTableJit(Table, CompiledExpression...) evaluates multiple JIT-compiled expressions in one compute_table_jit call. Output order follows the supplied expression order, and libcudf Row IR can eliminate structurally equivalent subexpressions across outputs.

For JIT-compiled expressions, literals are converted to one-row columns once during compilation and retained for repeated evaluation. Temporary scalar owners are released after construction completes. Default-compiled expressions retain the existing scalar-backed representation and do not incur the JIT literal-column allocation cost.

The binding also:

  • rejects compilation-mode mismatches, including passing default-compiled expressions to computeTableJit;
  • prevents JIT-compiled expressions from being passed to default-only consumers such as join and scan predicates;
  • validates null and closed inputs;
  • preserves the lifetime of input tables and compiled expressions across JNI calls.

This API is consumed by NVIDIA/cudf-spark#15312 to execute compatible Project expressions as multi-output AST JIT waves.

Validation

  • mvn -B -Dtest=CompiledExpressionTest surefire:test: 166 tests, 0 failures, 0 errors, 0 skipped.
  • Relevant cuDF pre-commit checks pass.
  • The downstream cudf-spark consumer builds successfully, and its targeted AST JIT and Project retry suites pass.

Checklist

  • I am familiar with the Contributing Guidelines.
  • New or existing tests cover these changes.
  • The documentation is up to date with these changes.

Expose computeTableJit to evaluate compiled AST roots in one libcudf call. Keep scalar-column-backed JIT trees alongside regular trees so compiled literals can be reused across evaluations.

Signed-off-by: Haoyang Li <haoyangl@nvidia.com>
@copy-pr-bot

copy-pr-bot Bot commented Aug 26, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@github-actions github-actions Bot added the Java Affects Java cuDF API. label Aug 26, 2026
@thirtiseven thirtiseven added feature request New feature or request Spark Functionality that helps Spark RAPIDS non-breaking Non-breaking change labels Aug 26, 2026
Signed-off-by: Haoyang Li <haoyangl@nvidia.com>
@coderabbitai

coderabbitai Bot commented Aug 27, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: d1056622-1813-4468-aa5e-35ed22c2d0ca

📥 Commits

Reviewing files that changed from the base of the PR and between 40c1844 and e37a829.

📒 Files selected for processing (7)
  • java/src/main/java/ai/rapids/cudf/ast/AstExpression.java
  • java/src/main/java/ai/rapids/cudf/ast/CompiledExpression.java
  • java/src/main/java/ai/rapids/cudf/ast/JitOperation.java
  • java/src/main/java/ai/rapids/cudf/ast/Literal.java
  • java/src/main/native/src/CompiledExpression.cpp
  • java/src/main/native/src/jni_compiled_expr.hpp
  • java/src/test/java/ai/rapids/cudf/ast/CompiledExpressionTest.java

Included review availability: Your plan provides up to 12 included reviews per hour; 11 remain after this review.


📝 Walkthrough

Summary by CodeRabbit

  • New Features

    • Added explicit JIT compilation for AST expressions.
    • Added support for evaluating multiple JIT expressions together as a table.
    • Added validation to prevent incompatible execution paths and inputs.
  • Bug Fixes

    • Improved resource safety during JIT evaluation.
    • Preserved input data when validation or computation fails.
  • Documentation

    • Updated guidance for using JIT compilation with JIT-specific operations and decimal literals.
  • Tests

    • Expanded coverage for JIT expressions, multiple outputs, literals, nullability, casting, overflow, and validation.

Walkthrough

The AST API now supports explicit default and JIT compilation modes. JIT expressions use mode-specific native execution and support multi-output table computation. Tests cover validation, literals, nullability, overflow, casts, and decimal behavior.

Changes

JIT AST execution

Layer / File(s) Summary
Java compilation and evaluation APIs
java/src/main/java/ai/rapids/cudf/ast/{AstExpression,CompiledExpression,JitOperation,Literal}.java
Adds compileJit(), stores compilation mode, adds computeTableJit, restricts incompatible native-handle access, and updates JIT documentation.
Native compilation modes
java/src/main/native/src/{jni_compiled_expr.hpp,CompiledExpression.cpp}
Stores compilation mode, creates JIT literal columns, validates JIT operations, releases staging scalars, and exposes separate compilation entry points.
Multi-output JIT execution
java/src/main/native/src/CompiledExpression.cpp
Replaces single-expression JIT computation with validated multi-output table evaluation.
JIT API validation and regression coverage
java/src/test/java/ai/rapids/cudf/ast/CompiledExpressionTest.java
Covers mode validation, handle restrictions, repeated inputs, literals, multi-output results, failures, overflow, casts, and decimal behavior.

Estimated code review effort: 4 (Complex) | ~45 minutes

Merge Risk: ⚪ Minimal · up to e37a8

The PR adds Java bindings for multi-output AST JIT with reported tests and downstream validation passing; no actionable merge-blocking risk remains.

Suggested reviewers: nartal1

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 21.31% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 61 functions across 7 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description check ✅ Passed The description clearly explains the Java bindings for multi-output AST JIT, compilation modes, validation, testing, and downstream use.
Title check ✅ Passed The title clearly summarizes the primary change: adding Java bindings for multi-output AST JIT.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
  • Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature request New feature or request Java Affects Java cuDF API. non-breaking Non-breaking change Spark Functionality that helps Spark RAPIDS

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant