Skip to content

feat(java-binding): generate jni method signature with macro - #12487

Merged
wenym1 merged 5 commits into
mainfrom
yiming/gen-jni-sig-macro
Sep 26, 2023
Merged

wenym1 merged 5 commits into
mainfrom
yiming/gen-jni-sig-macro

Conversation

@wenym1

@wenym1 wenym1 commented Sep 22, 2023

Copy link
Copy Markdown
Contributor

I hereby agree to the terms of the RisingWave Labs, Inc. Contributor License Agreement.

What's changed and what's your intention?

In this PR, we implement a macro gen_jni_sig that generates the jni signature from the java method signature. With this macro, we can avoid manually write the list of jni native and signature list when we register native method.

Besides, since we provide a register native function, in the java binding dynamic library, we don't have to export each jni method one by one. We change to provide a single method JNI_OnLoad, which will be called and register the jni method when the dynamic library is loaded.

Checklist

  • I have written necessary rustdoc comments
  • I have added necessary unit tests and integration tests
  • I have added fuzzing tests or opened an issue to track them. (Optional, recommended for new SQL features Sqlsmith: Sql feature generation #7934).
  • My PR contains breaking changes. (If it deprecates some features, please create a tracking issue to remove them in the future).
  • All checks passed in ./risedev check (or alias, ./risedev c)
  • My PR changes performance-critical code. (Please run macro/micro-benchmarks and show the results.)
  • My PR contains critical fixes that are necessary to be merged into the latest release. (Please check out the details)

Documentation

  • My PR needs documentation updates. (Please use the Release note section below to summarize the impact on users)

Release note

If this PR includes changes that directly affect users or other significant modifications relevant to the community, kindly draft a release note to provide a concise summary of these changes. Please prioritize highlighting the impact these changes will have on users.

@wenym1
wenym1 requested a review from a team as a code owner September 22, 2023 06:23
@github-actions github-actions Bot added the type/feature Type: New feature. label Sep 22, 2023
@wenym1
wenym1 requested review from chenzl25 and hzxa21 September 22, 2023 06:24
@codecov

codecov Bot commented Sep 22, 2023 •

Copy link
Copy Markdown

Codecov Report

Merging #12487 (d207f57) into main (d842cfa) will increase coverage by 0.29%.
The diff coverage is 62.18%.

❗ Current head d207f57 differs from pull request most recent head 83e2ab8. Consider uploading reports for the commit 83e2ab8 to get more accurate results

@@            Coverage Diff             @@
##             main   #12487      +/-   ##
==========================================
+ Coverage   69.42%   69.71%   +0.29%     
==========================================
  Files        1429     1426       -3     
  Lines      238628   236310    -2318     
==========================================
- Hits       165666   164752     -914     
+ Misses      72962    71558    -1404     
Flag Coverage Δ
rust 69.71% <62.18%> (+0.29%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Changed Coverage Δ
src/java_binding/src/lib.rs 0.00% <0.00%> (ø)
src/jni_core/src/jvm_runtime.rs 0.00% <0.00%> (ø)
src/jni_core/src/lib.rs 1.18% <0.00%> (-0.02%) ⬇️
src/jni_core/src/macros.rs 100.00% <100.00%> (ø)

... and 104 files with indirect coverage changes

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

Comment thread src/jni_core/src/lib.rs Outdated
let read_plan = Message::decode(to_guarded_slice(&read_plan, env)?.deref())?;
let iter = RUNTIME.block_on(HummockJavaBindingIterator::new(read_plan))?;
Ok(iter.into())
#[cfg(madsim)]

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.

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.

Great to know that there is such a useful macro. Thanks for the suggestion!

@chenzl25 chenzl25 left a comment

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.

LGTM! These macros are amazing! Maybe we can remove
the prefix Java_com_risingwave_java_binding_Binding_ so that we can have the same native method names in Rust.

@BugenZhao

Copy link
Copy Markdown
Contributor

LGTM! These macros are amazing! Maybe we can remove the prefix Java_com_risingwave_java_binding_Binding_ so that we can have the same native method names in Rust.

Find a crate for this -> https://crates.io/crates/jni_fn

@BugenZhao BugenZhao left a comment

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.

LGTM!

@wenym1

wenym1 commented Sep 26, 2023

Copy link
Copy Markdown
Contributor Author

Find a crate for this -> https://crates.io/crates/jni_fn

Just had a look at the crate. It aims to convert the method name to a name that is able to automatically recognized by jvm when loading the dynamic library. However, in this PR, we have changed to register the native methods manually instead of via a predefined name mapping rule, and therefore it's unnecessary for us to maintain the method name according to the rule with the macro in the crate.

@wenym1
wenym1 added this pull request to the merge queue Sep 26, 2023
Merged via the queue into main with commit b75ff79 Sep 26, 2023
@wenym1
wenym1 deleted the yiming/gen-jni-sig-macro branch September 26, 2023 06:27
BugenZhao pushed a commit that referenced this pull request Sep 27, 2023
…2123)

feat(java-binding): generate jni method signature with macro (#12487)

feat(streaming): recover `no_shuffle_backfill` (#12493)

feat(test): support customized source logic in deterministic test (#12456)

refactor(storage): reorg selector (#12392)

feat(frontend): add rw_catalog.rw_hummock_sstables (#12532)

chore: bump risingwave version in docker compose to 1.2.0 (#12530)

Signed-off-by: Bugen Zhao <i@bugenzhao.com>

refactor(sink): decouple sink formatter and payload writer (#12515)

chore(java-binding): refine stream chunk benchmark (#12504)

feat(meta): add create_type to `Table` (#12529)

refactor(sink): refine sink trait and macro (#12478)

refactor(backup): refine error message (#12388)

feat(sink): turn sink writer into higher level log sinker (#12152)

fix(over window): don't expect stream keys in UpdateDelete and UpdateInsert the same (#12536)

Signed-off-by: Richard Chien <stdrc@outlook.com>

refactor(expr): separate function implementations into a new crate (#12485)

Signed-off-by: Runji Wang <wangrunji0408@163.com>

fix(config): make metrics_level opt backward compatible (#12541)

refactor(connector): replace sink writer rpc with jni (#12480)

refactor(connector): remove `WriteGuard` and `fulfill_meta_column` from parser (#12542)

Signed-off-by: Bugen Zhao <i@bugenzhao.com>

feat(sink): handle stream key sink pk mismatch (#12458)

feat(optimizer): support apply hop window transpose rule (#12338)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type/feature Type: New feature.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants