Skip to content

Commit 9834a59

Browse files
committed
implement_custom_stabby_friendly_ffi
1 parent 65aa893 commit 9834a59

33 files changed

+385
-391
lines changed

Cargo.lock

Lines changed: 4 additions & 144 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

datafusion-examples/examples/ffi/ffi_example_table_provider/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ edition = { workspace = true }
2222
publish = false
2323

2424
[dependencies]
25-
abi_stable = "0.11.3"
2625
arrow = { workspace = true }
2726
datafusion = { workspace = true }
2827
datafusion-ffi = { workspace = true }

datafusion-examples/examples/ffi/ffi_example_table_provider/src/lib.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,12 @@
1717

1818
use std::sync::Arc;
1919

20-
use abi_stable::{export_root_module, prefix_type::PrefixTypeTrait};
2120
use arrow::array::RecordBatch;
2221
use arrow::datatypes::{DataType, Field, Schema};
2322
use datafusion::{common::record_batch, datasource::MemTable};
2423
use datafusion_ffi::proto::logical_extension_codec::FFI_LogicalExtensionCodec;
2524
use datafusion_ffi::table_provider::FFI_TableProvider;
26-
use ffi_module_interface::{TableProviderModule, TableProviderModuleRef};
25+
use ffi_module_interface::TableProviderModule;
2726

2827
fn create_record_batch(start_value: i32, num_values: usize) -> RecordBatch {
2928
let end_value = start_value + num_values as i32;
@@ -56,11 +55,10 @@ extern "C" fn construct_simple_table_provider(
5655
FFI_TableProvider::new_with_ffi_codec(Arc::new(table_provider), true, None, codec)
5756
}
5857

59-
#[export_root_module]
58+
#[unsafe(no_mangle)]
6059
/// This defines the entry point for using the module.
61-
pub fn get_simple_memory_table() -> TableProviderModuleRef {
60+
pub extern "C" fn ffi_example_get_module() -> TableProviderModule {
6261
TableProviderModule {
6362
create_table: construct_simple_table_provider,
6463
}
65-
.leak_into_prefix()
6664
}

datafusion-examples/examples/ffi/ffi_module_interface/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,4 @@ publish = false
2525
workspace = true
2626

2727
[dependencies]
28-
abi_stable = "0.11.3"
2928
datafusion-ffi = { workspace = true }

datafusion-examples/examples/ffi/ffi_module_interface/src/lib.rs

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -15,36 +15,17 @@
1515
// specific language governing permissions and limitations
1616
// under the License.
1717

18-
use abi_stable::{
19-
StableAbi, declare_root_module_statics,
20-
library::{LibraryError, RootModule},
21-
package_version_strings,
22-
sabi_types::VersionStrings,
23-
};
2418
use datafusion_ffi::proto::logical_extension_codec::FFI_LogicalExtensionCodec;
2519
use datafusion_ffi::table_provider::FFI_TableProvider;
2620

27-
#[repr(C)]
28-
#[derive(StableAbi)]
29-
#[sabi(kind(Prefix(prefix_ref = TableProviderModuleRef)))]
3021
/// This struct defines the module interfaces. It is to be shared by
3122
/// both the module loading program and library that implements the
3223
/// module. It is possible to move this definition into the loading
3324
/// program and reference it in the modules, but this example shows
3425
/// how a user may wish to separate these concerns.
26+
#[repr(C)]
3527
pub struct TableProviderModule {
3628
/// Constructs the table provider
3729
pub create_table:
3830
extern "C" fn(codec: FFI_LogicalExtensionCodec) -> FFI_TableProvider,
3931
}
40-
41-
impl RootModule for TableProviderModuleRef {
42-
declare_root_module_statics! {TableProviderModuleRef}
43-
const BASE_NAME: &'static str = "ffi_example_table_provider";
44-
const NAME: &'static str = "ffi_example_table_provider";
45-
const VERSION_STRINGS: VersionStrings = package_version_strings!();
46-
47-
fn initialization(self) -> Result<Self, LibraryError> {
48-
Ok(self)
49-
}
50-
}

datafusion-examples/examples/ffi/ffi_module_loader/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ publish = false
2525
workspace = true
2626

2727
[dependencies]
28-
abi_stable = "0.11.3"
2928
datafusion = { workspace = true }
3029
datafusion-ffi = { workspace = true }
3130
ffi_module_interface = { path = "../ffi_module_interface" }
31+
libloading = "0.8"
3232
tokio = { workspace = true, features = ["rt-multi-thread", "parking_lot"] }

0 commit comments

Comments
 (0)