timsaucer commented on code in PR #18672:
URL: https://github.com/apache/datafusion/pull/18672#discussion_r2556703644
##########
datafusion/ffi/src/lib.rs:
##########
@@ -58,5 +58,33 @@ pub extern "C" fn version() -> u64 {
version.major
}
+static LIBRARY_MARKER: u8 = 0;
+
+/// This utility is used to determine if two FFI structs are within
+/// the same library. It is possible that the interplay between
+/// foreign and local functions calls create one FFI struct that
+/// references another. It is helpful to determine if a foreign
+/// struct is truly foreign or in the same library. If we are in the
+/// same library, then we can access the underlying types directly.
+///
+/// This function works by checking the address of the library
+/// marker. Each library that implements the FFI code will have
+/// a different address for the marker. By checking the marker
+/// address we can determine if a struct is truly Foreign or is
Review Comment:
It *could* be a second instance of the same library and that would give a
different address. In practice I don't think this is a problem, though. The
code would still work, they just wouldn't get the benefit of this marker id
work. It would work as previous to this PR.
I don't think it's a problem in practice because it would mean importing the
same library twice. The canonical example of datafusion-python doesn't do that.
There *may* be an edge case somewhere. Related is [this
discussion](https://github.com/apache/datafusion/pull/18672#issuecomment-3568686771),
but that is a lot of effort for minimal return IMO.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]