Package ai.rapids.cudf
Class NativeDepsLoader
java.lang.Object
ai.rapids.cudf.NativeDepsLoader
This class will load the native dependencies.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic boolean
static File
loadNativeDep
(String depName, boolean preserveDep) Allows other libraries to reuse the same native deps loading logic.static void
Load the native libraries needed for libcudf, if not loaded already.static void
loadNativeDeps
(String[] loadOrder) Allows other libraries to reuse the same native deps loading logic.static void
loadNativeDeps
(String[] loadOrder, boolean preserveDeps) Allows other libraries to reuse the same native deps loading logic.
-
Constructor Details
-
NativeDepsLoader
public NativeDepsLoader()
-
-
Method Details
-
loadNativeDeps
public static void loadNativeDeps()Load the native libraries needed for libcudf, if not loaded already. -
loadNativeDeps
Allows other libraries to reuse the same native deps loading logic. Libraries will be searched for under ${os.arch}/${os.name}/ in the class path using the class loader for this class.
Because this just loads the libraries and loading the libraries themselves needs to be a singleton operation it is recommended that any library using this provide their own wrapper function similar toprivate static boolean loaded = false; static synchronized void loadNativeDeps() { if (!loaded) { try { // If you also depend on the cudf liobrary being loaded, be sure it is loaded // first ai.rapids.cudf.NativeDepsLoader.loadNativeDeps(); ai.rapids.cudf.NativeDepsLoader.loadNativeDeps(new String[]{...}); loaded = true; } catch (Throwable t) { log.error("Could not load ...", t); } } }
This function should be called from the static initialization block of any class that uses JNI. For examplepublic class UsesJNI { static { MyNativeDepsLoader.loadNativeDeps(); } }
- Parameters:
loadOrder
- the base name of the libraries. For example libfoo.so would be passed in as "foo". The libraries are loaded in the order provided.- Throws:
IOException
- on any error trying to load the libraries.
-
loadNativeDeps
Allows other libraries to reuse the same native deps loading logic. Libraries will be searched for under ${os.arch}/${os.name}/ in the class path using the class loader for this class.
Because this just loads the libraries and loading the libraries themselves needs to be a singleton operation it is recommended that any library using this provide their own wrapper function similar toprivate static boolean loaded = false; static synchronized void loadNativeDeps() { if (!loaded) { try { // If you also depend on the cudf liobrary being loaded, be sure it is loaded // first ai.rapids.cudf.NativeDepsLoader.loadNativeDeps(); ai.rapids.cudf.NativeDepsLoader.loadNativeDeps(new String[]{...}); loaded = true; } catch (Throwable t) { log.error("Could not load ...", t); } } }
This function should be called from the static initialization block of any class that uses JNI. For examplepublic class UsesJNI { static { MyNativeDepsLoader.loadNativeDeps(); } }
- Parameters:
loadOrder
- the base name of the libraries. For example libfoo.so would be passed in as "foo". The libraries are loaded in the order provided.preserveDeps
- if false the dependencies will be deleted immediately after loading rather than on exit.- Throws:
IOException
- on any error trying to load the libraries.
-
loadNativeDep
Allows other libraries to reuse the same native deps loading logic. Library will be searched for under ${os.arch}/${os.name}/ in the class path using the class loader for this class.- Parameters:
depName
- the base name of the library. For example libfoo.so would be passed in as "foo". The libraries are loaded in the order provided.preserveDep
- if false the dependencies will be deleted immediately after loading rather than on exit.- Returns:
- path where the dependency was loaded
- Throws:
IOException
- on any error trying to load the libraries.
-
libraryLoaded
public static boolean libraryLoaded()
-