Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add FFI from_raw #5082

Merged
merged 1 commit into from
Nov 17, 2023
Merged

Add FFI from_raw #5082

merged 1 commit into from
Nov 17, 2023

Conversation

tustvold
Copy link
Contributor

Which issue does this PR close?

Closes #.

Rationale for this change

This makes it easier to correctly move data across FFI boundaries

What changes are included in this PR?

Are there any user-facing changes?

@github-actions github-actions bot added the arrow Changes to the arrow crate label Nov 16, 2023
Copy link
Member

@pitrou pitrou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM on the principle, but I'm not a Rust developer :-)

/// [move]: https://arrow.apache.org/docs/format/CDataInterface.html#moving-an-array
/// [valid]: https://doc.rust-lang.org/std/ptr/index.html#safety
pub unsafe fn from_raw(array: *mut FFI_ArrowArray) -> Self {
std::ptr::replace(array, Self::empty())
Copy link
Contributor Author

@tustvold tustvold Nov 16, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something that occurs to me is we don't verify that release isn't NULL, as it can't be an invariant that FFI_ArrowArray doesn't have a null release callback for obvious reasons, but then the accessors assume the data is valid. Perhaps we should be asserting that FFI_ArrowArray hasn't been released in the accessors?

The good news is I don't think you can hit this with safe code, but it is potentially interesting

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Asserting that the release pointer isn't NULL sounds good to me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
arrow Changes to the arrow crate
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants