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

[R] import_from_c() / export_to_c() methods should accept external pointers #30339

Closed
asfimport opened this issue Nov 24, 2021 · 2 comments
Closed

Comments

@asfimport
Copy link
Collaborator

asfimport commented Nov 24, 2021

The import and export to C methods for Field, Shema, DataType, Array, RecordBatch, and RecordBatchReader all require the pointer to be passed as a double (casted from uintptr_t casted from *. I imagine there's good reason for this path to exist; however, the R externalptr type and 64-bit integer are more natural types and I think it would not be hard to allow pointers to be passed in this way. A short discussion of this occurred when updating the Python docs on how to pass Array pointers to R.

The implementation lives in arrow_cpp11.h and it seems like it would be easy to allow a user to pass something more R-like while still keeping the double route open for the packages that need it.

I see that this is getting used for pointers that R6 objects are storing for the underlying C++ objects...I imagine there's a good reason for this but I wonder if there's a way to make the places where this interacts with other packages more intuitive.

Reporter: Dewey Dunnington / @paleolimbot
Assignee: Alessandro Molina / @amol-

Related issues:

PRs and other links:

Note: This issue was originally created as ARROW-14804. Please see the migration documentation for further details.

@asfimport
Copy link
Collaborator Author

Antoine Pitrou / @pitrou:
Not only dedicated pointer types may be "more natural", but double is actually insufficient. A double precision floating-point number has 53 bits of mantissa, which is not enough to represent every possible 64-bit pointer.

I suppose pointer values are often clustered around 0, which makes them exactly representable as a double, but that's just luck and there's no guarantee that pointers will always be like that.

@asfimport
Copy link
Collaborator Author

Jonathan Keane / @jonkeane:
Issue resolved by pull request 11919
#11919

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

No branches or pull requests

2 participants