From c6ee2966625426348e34ca79d3409a8f0767ad89 Mon Sep 17 00:00:00 2001 From: Logan Riggs Date: Fri, 13 Dec 2024 09:31:31 -0800 Subject: [PATCH 1/3] Fix package error for jna include. --- gandiva/src/main/java/module-info.java | 1 + 1 file changed, 1 insertion(+) diff --git a/gandiva/src/main/java/module-info.java b/gandiva/src/main/java/module-info.java index 49deed185..9724a97df 100644 --- a/gandiva/src/main/java/module-info.java +++ b/gandiva/src/main/java/module-info.java @@ -26,4 +26,5 @@ requires org.apache.arrow.memory.core; requires org.apache.arrow.vector; requires org.slf4j; + requires com.sun.jna; } From 734af1602a00d14e6a46e0bfe6ebcfe00f870096 Mon Sep 17 00:00:00 2001 From: DenisTarasyuk Date: Tue, 16 Apr 2024 19:09:52 +0300 Subject: [PATCH 2/3] DX-88565 Fixed gandiva native library loading option to be global Added jna library which allows more control over native code loading --- .../org/apache/arrow/gandiva/evaluator/JniLoader.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/gandiva/src/main/java/org/apache/arrow/gandiva/evaluator/JniLoader.java b/gandiva/src/main/java/org/apache/arrow/gandiva/evaluator/JniLoader.java index 6f4cdc58c..65fcd086a 100644 --- a/gandiva/src/main/java/org/apache/arrow/gandiva/evaluator/JniLoader.java +++ b/gandiva/src/main/java/org/apache/arrow/gandiva/evaluator/JniLoader.java @@ -23,6 +23,7 @@ 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; @@ -31,6 +32,9 @@ /** 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; @@ -69,6 +73,10 @@ private static void loadGandivaLibraryFromJar(final String tmpDir) final String libraryToLoad = LIBRARY_NAME + "/" + 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()); } From eb3cfd2723c70400bc1737808dcda2ab5933c76b Mon Sep 17 00:00:00 2001 From: Logan Riggs Date: Fri, 14 Feb 2025 11:28:41 -0800 Subject: [PATCH 3/3] Dremio updates --- .../org/apache/arrow/gandiva/evaluator/JniLoader.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/gandiva/src/main/java/org/apache/arrow/gandiva/evaluator/JniLoader.java b/gandiva/src/main/java/org/apache/arrow/gandiva/evaluator/JniLoader.java index 65fcd086a..5c59c219e 100644 --- a/gandiva/src/main/java/org/apache/arrow/gandiva/evaluator/JniLoader.java +++ b/gandiva/src/main/java/org/apache/arrow/gandiva/evaluator/JniLoader.java @@ -18,6 +18,8 @@ import static java.util.UUID.randomUUID; +import com.sun.jna.Library; +import com.sun.jna.NativeLibrary; import java.io.File; import java.io.IOException; import java.io.InputStream; @@ -32,9 +34,9 @@ /** 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 final int RTLD_LAZY = 0x00001; private static volatile JniLoader INSTANCE; private static volatile long defaultConfiguration = 0L; @@ -75,8 +77,7 @@ private static void loadGandivaLibraryFromJar(final String tmpDir) final File libraryFile = moveFileFromJarToTemp(tmpDir, libraryToLoad, LIBRARY_NAME); NativeLibrary.getInstance( libraryFile.getAbsolutePath(), - Collections.singletonMap(Library.OPTION_OPEN_FLAGS, new Integer(RTLD_LAZY | RTLD_GLOBAL)) - ); + Collections.singletonMap(Library.OPTION_OPEN_FLAGS, new Integer(RTLD_LAZY | RTLD_GLOBAL))); System.load(libraryFile.getAbsolutePath()); }