Skip to content

[CORE] Add reusable JNI input adapters for backend runtimes#12535

Open
wangxinshuo-bolt wants to merge 2 commits into
apache:mainfrom
wangxinshuo-bolt:pr/core-jni-backend-adapters
Open

[CORE] Add reusable JNI input adapters for backend runtimes#12535
wangxinshuo-bolt wants to merge 2 commits into
apache:mainfrom
wangxinshuo-bolt:pr/core-jni-backend-adapters

Conversation

@wangxinshuo-bolt

@wangxinshuo-bolt wangxinshuo-bolt commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

What changes are proposed in this pull request?

This PR adds reusable JNI input-adapter extension points for backend runtimes.

Previously, PlanEvaluatorJniWrapper always created JniColumnarBatchIterator directly. This prevented backends that require custom input handling from reusing the common plan-evaluation JNI workflow.

This PR:

  • Adds Runtime::createJniInputIterator() as an overridable factory, with a default implementation that preserves the existing behavior.
  • Passes the JNI environment, Java iterator, and iterator index through JniInputIteratorContext.
  • Updates PlanEvaluatorJniWrapper to create input iterators through the runtime factory.
  • Exposes makeShuffleStreamReader() so backends can reuse the common Java-to-native shuffle stream adapter.

With these changes, a backend can customize JNI input handling without duplicating the common JNI wrapper logic.

How was this patch tested?

  • Built and linked the affected native core targets.
  • Verified that the JNI environment, Java iterator object, and iterator index are forwarded through the virtual runtime factory, and that a backend runtime override can return its own ColumnarBatchIterator implementation.

Was this patch authored or co-authored using generative AI tooling?

Yes.

Generated-by: Codex GPT-5

@github-actions github-actions Bot added the VELOX label Jul 16, 2026
Comment thread cpp/core/tests/JniInputIteratorTest.cc Outdated
namespace gluten {

std::shared_ptr<StreamReader> makeShuffleStreamReader(JNIEnv* env, jobject jShuffleStreamReader) {
return std::make_shared<::ShuffleStreamReader>(env, jShuffleStreamReader);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove "::"

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove "::"

::ClassName means: look for ClassName in the global namespace. It avoids name conflicts by explicitly referring to the class in the global namespace.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is merely a defensive strategy intended to prevent misuse.


namespace gluten {

std::shared_ptr<StreamReader> makeShuffleStreamReader(JNIEnv* env, jobject jShuffleStreamReader) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we need to wrap it.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we need to wrap it.

ShuffleStreamReader is a private implementation within JniWrapper.cc; we need a function to expose the mechanism for creating ShuffleStreamReader instances for different backends.

@wangxinshuo-bolt
wangxinshuo-bolt force-pushed the pr/core-jni-backend-adapters branch from bee9bdd to c436dce Compare July 16, 2026 09:30
@wangxinshuo-bolt
wangxinshuo-bolt marked this pull request as ready for review July 16, 2026 12:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants