Skip to content
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

DX-88565 Fixed gandiva native library loading option to be global #69

Merged
merged 1 commit into from
Apr 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions java/gandiva/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<protobuf.version>3.25.1</protobuf.version>
<jna.version>5.14.0</jna.version>
<checkstyle.failOnViolation>true</checkstyle.failOnViolation>
<arrow.cpp.build.dir>../../../cpp/release-build</arrow.cpp.build.dir>
</properties>
Expand Down Expand Up @@ -62,6 +63,11 @@
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>
<dependency>
<groupId>net.java.dev.jna</groupId>
<artifactId>jna</artifactId>
<version>${jna.version}</version>
</dependency>
</dependencies>
<profiles>
<profile>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,24 @@
import java.io.InputStream;
import java.nio.file.Files;
import java.nio.file.StandardCopyOption;
import java.util.Collections;
import java.util.Locale;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;

import org.apache.arrow.gandiva.exceptions.GandivaException;

import com.sun.jna.Library;
import com.sun.jna.NativeLibrary;

/**
* This class handles loading of the jni library, and acts as a bridge for the native functions.
*/
class JniLoader {
private static final String LIBRARY_NAME = "gandiva_jni";

private static final int RTLD_GLOBAL = 0x00100;
private static final int RTLD_LAZY = 0x00001;

private static volatile JniLoader INSTANCE;
private static volatile long defaultConfiguration = 0L;
Expand Down Expand Up @@ -73,6 +80,10 @@ private static void loadGandivaLibraryFromJar(final String tmpDir)
final String libraryToLoad =
getNormalizedArch() + "/" + System.mapLibraryName(LIBRARY_NAME);
final File libraryFile = moveFileFromJarToTemp(tmpDir, libraryToLoad, LIBRARY_NAME);
NativeLibrary.getInstance(
libraryFile.getAbsolutePath(),
Collections.singletonMap(Library.OPTION_OPEN_FLAGS, new Integer(RTLD_LAZY | RTLD_GLOBAL))
);
System.load(libraryFile.getAbsolutePath());
}

Expand Down
Loading