From 88bf478a3d78e3778406dc867a22ecf9ef4a899d Mon Sep 17 00:00:00 2001 From: Fenjin Wang Date: Mon, 14 Mar 2022 01:51:29 +0000 Subject: [PATCH 1/3] Revert "Don't use Arc::from_raw when importing ArrowArray and ArrowSchema (#1334)" This reverts commit f84c4364d5e1cd5879f5ef9cc6441cdf233df8c3. --- arrow/src/ffi.rs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/arrow/src/ffi.rs b/arrow/src/ffi.rs index 461995bdbaf..e0633081e95 100644 --- a/arrow/src/ffi.rs +++ b/arrow/src/ffi.rs @@ -107,7 +107,7 @@ bitflags! { /// See /// This was created by bindgen #[repr(C)] -#[derive(Debug, Clone)] +#[derive(Debug)] pub struct FFI_ArrowSchema { format: *const c_char, name: *const c_char, @@ -336,7 +336,7 @@ fn bit_width(data_type: &DataType, i: usize) -> Result { /// See /// This was created by bindgen #[repr(C)] -#[derive(Debug, Clone)] +#[derive(Debug)] pub struct FFI_ArrowArray { pub(crate) length: i64, pub(crate) null_count: i64, @@ -781,11 +781,9 @@ impl ArrowArray { .to_string(), )); }; - let ffi_array = (*array).clone(); - let ffi_schema = (*schema).clone(); Ok(Self { - array: Arc::new(ffi_array), - schema: Arc::new(ffi_schema), + array: Arc::from_raw(array as *mut FFI_ArrowArray), + schema: Arc::from_raw(schema as *mut FFI_ArrowSchema), }) } From d34c02b7431e2f5c1e9252e6fe6d4f43358bbc74 Mon Sep 17 00:00:00 2001 From: Fenjin Wang Date: Mon, 14 Mar 2022 02:53:05 +0000 Subject: [PATCH 2/3] add make_array_from_box --- arrow/src/array/array.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/arrow/src/array/array.rs b/arrow/src/array/array.rs index 795439ec80a..3018967f5a5 100644 --- a/arrow/src/array/array.rs +++ b/arrow/src/array/array.rs @@ -620,6 +620,19 @@ fn new_null_sized_array( }) } +/// Creates a new array from two FFI pointers. Used to import arrays from the C Data Interface +/// # Safety +/// Assumes that these pointers represent valid C Data Interfaces, both in memory +/// representation and lifetime via the `release` mechanism. +pub unsafe fn make_array_from_box( + array: *const ffi::FFI_ArrowArray, + schema: *const ffi::FFI_ArrowSchema, +) -> Result { + let array = Arc::into_raw(Arc::from(Box::from_raw(array as *mut _))); + let schema = Arc::into_raw(Arc::from(Box::from_raw(schema as *mut _))); + make_array_from_raw(array, schema) +} + /// Creates a new array from two FFI pointers. Used to import arrays from the C Data Interface /// # Safety /// Assumes that these pointers represent valid C Data Interfaces, both in memory From 8ce3fd77cc194c1ed9bf6b7cf61f2fdf7aa296d9 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 18 Jan 2023 13:08:40 +0000 Subject: [PATCH 3/3] Update pyo3 requirement from 0.16 to 0.18 Updates the requirements on [pyo3](https://github.com/pyo3/pyo3) to permit the latest version. - [Release notes](https://github.com/pyo3/pyo3/releases) - [Changelog](https://github.com/PyO3/pyo3/blob/main/CHANGELOG.md) - [Commits](https://github.com/pyo3/pyo3/compare/v0.16.0...v0.18.0) --- updated-dependencies: - dependency-name: pyo3 dependency-type: direct:production ... Signed-off-by: dependabot[bot] --- arrow/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arrow/Cargo.toml b/arrow/Cargo.toml index ffdd2196b07..350171da3a7 100644 --- a/arrow/Cargo.toml +++ b/arrow/Cargo.toml @@ -53,7 +53,7 @@ chrono-tz = {version = "0.6", optional = true} flatbuffers = { version = "=2.1.1", optional = true } hex = "0.4" comfy-table = { version = "5.0", optional = true, default-features = false } -pyo3 = { version = "0.16", optional = true } +pyo3 = { version = "0.18", optional = true } lexical-core = "^0.8" multiversion = "0.6.1" bitflags = "1.2.1"