From 5af7688301cfa561d0378d86292eacf9f8ee6c07 Mon Sep 17 00:00:00 2001 From: weiting-chen Date: Tue, 23 Mar 2021 15:54:52 +0800 Subject: [PATCH] Fix issue0191 for .so file copy to tmp. --- .../src/main/java/com/intel/oap/vectorized/JniUtils.java | 8 ++++++++ native-sql-engine/cpp/src/CMakeLists.txt | 5 +++++ 2 files changed, 13 insertions(+) diff --git a/native-sql-engine/core/src/main/java/com/intel/oap/vectorized/JniUtils.java b/native-sql-engine/core/src/main/java/com/intel/oap/vectorized/JniUtils.java index e65c4b39e..cd5f774dc 100644 --- a/native-sql-engine/core/src/main/java/com/intel/oap/vectorized/JniUtils.java +++ b/native-sql-engine/core/src/main/java/com/intel/oap/vectorized/JniUtils.java @@ -39,6 +39,8 @@ /** Helper class for JNI related operations. */ public class JniUtils { private static final String LIBRARY_NAME = "spark_columnar_jni"; + private static final String ARROW_LIBRARY_NAME = "libarrow.so.300"; + private static final String GANDIVA_LIBRARY_NAME = "libgandiva.so.300"; private static boolean isLoaded = false; private static boolean isCodegenDependencyLoaded = false; private static List codegenJarsLoadedCache = new ArrayList<>(); @@ -77,6 +79,8 @@ private JniUtils(String _tmp_dir) throws IOException, IllegalAccessException, Il try { loadLibraryFromJar(tmp_dir); } catch (IOException ex) { + System.load(ARROW_LIBRARY_NAME); + System.load(GANDIVA_LIBRARY_NAME); System.loadLibrary(LIBRARY_NAME); } isLoaded = true; @@ -108,6 +112,10 @@ static void loadLibraryFromJar(String tmp_dir) throws IOException, IllegalAccess if (tmp_dir == null) { tmp_dir = System.getProperty("java.io.tmpdir"); } + final File arrowlibraryFile = moveFileFromJarToTemp(tmp_dir, ARROW_LIBRARY_NAME); + System.load(arrowlibraryFile.getAbsolutePath()); + final File gandivalibraryFile = moveFileFromJarToTemp(tmp_dir, GANDIVA_LIBRARY_NAME); + System.load(gandivalibraryFile.getAbsolutePath()); final String libraryToLoad = System.mapLibraryName(LIBRARY_NAME); final File libraryFile = moveFileFromJarToTemp(tmp_dir, libraryToLoad); System.load(libraryFile.getAbsolutePath()); diff --git a/native-sql-engine/cpp/src/CMakeLists.txt b/native-sql-engine/cpp/src/CMakeLists.txt index ded32023c..8e13ec41f 100644 --- a/native-sql-engine/cpp/src/CMakeLists.txt +++ b/native-sql-engine/cpp/src/CMakeLists.txt @@ -294,6 +294,11 @@ macro(find_arrow) message(STATUS "Gandiva Library Can Be Found in ${GANDIVA_LIB}") endif() + file(COPY ${ARROW_LIB}.0.0 DESTINATION ${root_directory}/releases/) + file(COPY ${ARROW_LIB} DESTINATION ${root_directory}/releases/) + file(COPY ${GANDIVA_LIB}.0.0 DESTINATION ${root_directory}/releases/) + file(COPY ${GANDIVA_LIB} DESTINATION ${root_directory}/releases/) + target_link_libraries(spark_columnar_jni LINK_PUBLIC ${ARROW_LIB} ${GANDIVA_LIB}) target_include_directories(spark_columnar_jni PUBLIC ${ARROW_INCLUDE_DIR})