Skip to content

Commit 19b56a8

Browse files
author
Jiayu Liu
committed
update dockerfile, fix library path
1 parent 5d9765e commit 19b56a8

3 files changed

Lines changed: 10 additions & 44 deletions

File tree

Dockerfile

Lines changed: 3 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
# build jni
2-
FROM debian:bullseye as rust-builder
1+
FROM openjdk:11-jdk-slim-bullseye
32

43
ENV DEBIAN_FRONTEND noninteractive
54

@@ -11,15 +10,6 @@ RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
1110

1211
ENV PATH="/root/.cargo/bin:$PATH"
1312

14-
COPY datafusion-jni /usr/opt/datafusion-jni
15-
16-
WORKDIR /usr/opt/datafusion-jni
17-
18-
RUN cargo build --release
19-
20-
# build java
21-
FROM openjdk:17-jdk-slim-bullseye AS java-builder
22-
2313
WORKDIR /usr/opt/datafusion-java
2414

2515
COPY build.gradle settings.gradle gradlew ./
@@ -30,16 +20,6 @@ RUN ./gradlew --version
3020

3121
COPY . .
3222

33-
RUN ./gradlew installDist
34-
35-
FROM openjdk:17-jdk-slim-bullseye
36-
37-
WORKDIR /usr/opt/datafusion-java
38-
39-
COPY --from=rust-builder /usr/opt/datafusion-jni/target/release/libdatafusion_jni.so ./
40-
41-
COPY --from=java-builder /usr/opt/datafusion-java/datafusion-examples/build/install/datafusion-examples ./
42-
43-
CMD ["--class-path", "/usr/opt/datafusion-java/lib/*", "-R", "-Djava.library.path=/usr/opt/datafusion-java"]
23+
RUN ./gradlew cargoReleaseBuild build installDist
4424

45-
ENTRYPOINT ["jshell"]
25+
ENTRYPOINT ["./datafusion-examples/build/install/datafusion-examples/bin/datafusion-examples"]

README.md

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -21,27 +21,11 @@ dependencies {
2121
implementation(
2222
group = "io.github.datafusion-contrib",
2323
name = "datafusion-java",
24-
version = "0.7.1" // or latest version, checkout https://github.com/datafusion-contrib/datafusion-java/releases
24+
version = "0.9.0" // or latest version, checkout https://github.com/datafusion-contrib/datafusion-java/releases
2525
)
2626
}
2727
```
2828

29-
Additionally, given this is a JNI project, you'll need to download the pre-built binary to be loaded during runtime. The pre-built libraries are compiled, signed, and verified from GitHub workflow actions, and are made available in https://repo.maven.apache.org/maven2/io/github/datafusion-contrib/datafusion-java/{a.b.c}/ where `{a.b.c}` is the latest version:
30-
31-
- `datafusion-java-a.b.c.so` is for linux-x86_64 machines
32-
- `datafusion-java-a.b.c.dylib` is for macOS machines
33-
34-
Additionally you are encouraged to check the GPG signature as well as the sha256 sum of the binaries just to be sure.
35-
36-
Once downloaded, rename the library as `libdatafusion_jni.so` or `libdatafusion_jni.dylib` and put it to a directory readable by your application. During startup time, make sure you pass:
37-
38-
```bash
39-
# or use gradle run but supply --args instead
40-
java -Djava.library.path=/Users/me/dir/to/jni/library/ ...
41-
```
42-
43-
to the command line.
44-
4529
To test it out, you can use this piece of demo code:
4630

4731
<details>

datafusion-java/src/main/java/org/apache/arrow/datafusion/JNILoader.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,11 @@ private static OsName getOsName() {
4141
}
4242
}
4343

44+
/**
45+
* @return the absolute path in the jar file for the jni library
46+
*/
4447
private static String getResourceName() {
45-
return String.format("lib%s.%s", libraryName, getExtension());
48+
return String.format("/jni_libs/lib%s.%s", libraryName, getExtension());
4649
}
4750

4851
private static String getExtension() {
@@ -54,16 +57,15 @@ private static String getExtension() {
5457
} else if (osName == OsName.Windows) {
5558
return "dll";
5659
}
57-
throw new IllegalStateException("Cannot determin extension for " + osName);
60+
throw new IllegalStateException("Cannot determine the extension for " + osName);
5861
}
5962

6063
static synchronized void load() {
6164
if (loaded.get()) {
6265
logger.debug("{} already loaded, returning", libraryName);
6366
return;
6467
}
65-
String resourceName = getResourceName();
66-
InputStream is = JNILoader.class.getResourceAsStream(resourceName);
68+
InputStream is = JNILoader.class.getResourceAsStream(getResourceName());
6769
if (is == null) {
6870
try {
6971
System.loadLibrary(libraryName);

0 commit comments

Comments
 (0)