-
Notifications
You must be signed in to change notification settings - Fork 106
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(java/driver/jni): add JNI bindings to native driver manager #2401
base: main
Are you sure you want to change the base?
Conversation
1abdf50
to
7df6826
Compare
java/driver/jni/src/main/java/org/apache/arrow/adbc/driver/jni/JniDriver.java
Outdated
Show resolved
Hide resolved
java/driver/jni/src/main/java/org/apache/arrow/adbc/driver/jni/impl/JniLoader.java
Show resolved
Hide resolved
java/driver/jni/src/main/java/org/apache/arrow/adbc/driver/jni/impl/JniLoader.java
Outdated
Show resolved
Hide resolved
java/driver/jni/src/main/java/org/apache/arrow/adbc/driver/jni/impl/JniLoader.java
Outdated
Show resolved
Hide resolved
java/driver/jni/src/main/java/org/apache/arrow/adbc/driver/jni/impl/NativeAdbcException.java
Outdated
Show resolved
Hide resolved
java/driver/jni/src/main/java/org/apache/arrow/adbc/driver/jni/impl/NativeQueryResult.java
Outdated
Show resolved
Hide resolved
Alright, this is now minimally functional and building, I'm going to add CI support, more tests/features, etc. in follow up PRs. It won't be part of releases for now (it has to be manually enabled). |
add_custom_command(OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/target/headers/org_apache_arrow_adbc_driver_jni_impl_NativeAdbc.h | ||
COMMENT "Generate JNI headers" | ||
# Force Maven to actually re-run the command | ||
COMMAND rm -rf ${CMAKE_CURRENT_SOURCE_DIR}/target/headers | ||
${CMAKE_CURRENT_SOURCE_DIR}/target/maven-status | ||
COMMAND mvn --file ${CMAKE_CURRENT_SOURCE_DIR}/../.. -Pjni,javah | ||
compile --also-make --projects :adbc-driver-jni | ||
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/src/main/java/org/apache/arrow/adbc/driver/jni/impl/NativeAdbc.java | ||
) | ||
|
||
add_library(adbc_driver_jni SHARED | ||
src/main/cpp/jni_wrapper.cc | ||
${CMAKE_CURRENT_SOURCE_DIR}/target/headers/org_apache_arrow_adbc_driver_jni_impl_NativeAdbc.h | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CMake projects add_jar()
https://cmake.org/cmake/help/latest/module/UseJava.html#creating-and-installing-jars .
Does it help this?
FYI: apache/arrow-java uses add_jar()
when I prepared it: https://github.com/apache/arrow-java/blob/d304da5f872615346557e947ca5b04e9e23e8b87/dataset/CMakeLists.txt#L24-L32
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's what I originally did! 😂
But it has some problems. CMake can't resolve the Maven dependency tree. So the files we pass to add_jar
have to be able to compile without any dependencies, including any dependencies on other ADBC classes. That meant duplicating code or writing slightly unnatural code in Java. So @laurentgo here suggested using CMake to invoke Maven to generate the headers instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, sorry!
Fixes #2027.