MCPcopy Create free account
hub / github.com/apache/datafusion / get_module

Function get_module

datafusion/ffi/src/tests/utils.rs:74–107  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

72}
73
74pub fn get_module() -> Result<ForeignLibraryModule> {
75 let expected_version = crate::version();
76
77 let crate_root = Path::new(env!("CARGO_MANIFEST_DIR"));
78 let target_dir = crate_root
79 .parent()
80 .expect("Failed to find crate parent")
81 .parent()
82 .expect("Failed to find workspace root")
83 .join("target");
84
85 let library_dir = compute_library_dir(target_dir.as_path());
86 let lib_path = find_cdylib(&library_dir.join("deps"))?;
87
88 // Load the library using libloading
89 let lib = unsafe {
90 libloading::Library::new(&lib_path)
91 .map_err(|e| DataFusionError::External(Box::new(e)))?
92 };
93
94 let get_module: libloading::Symbol<extern "C" fn() -> ForeignLibraryModule> = unsafe {
95 lib.get(b"datafusion_ffi_get_module")
96 .map_err(|e| DataFusionError::External(Box::new(e)))?
97 };
98
99 let module = get_module();
100
101 assert_eq!((module.version)(), expected_version);
102
103 // Leak the library to keep it loaded for the duration of the test
104 std::mem::forget(lib);
105
106 Ok(module)
107}

Calls 6

versionFunction · 0.85
newFunction · 0.85
compute_library_dirFunction · 0.85
find_cdylibFunction · 0.85
joinMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…