viirya commented on code in PR #905:
URL: https://github.com/apache/datafusion-comet/pull/905#discussion_r1744037235
##########
native/core/src/execution/utils.rs:
##########
@@ -96,6 +100,25 @@ impl SparkArrowConvert for ArrayData {
Ok((array as i64, schema as i64))
}
+
+ /// Move this ArrowData to pointers of Arrow C data interface.
+ fn move_to_spark(&self, array: i64, schema: i64) -> Result<(),
ExecutionError> {
+ let jvm_array =
+ unsafe { std::ptr::replace(array as *mut FFI_ArrowArray,
FFI_ArrowArray::new(self)) };
+ let jvm_schema = unsafe {
+ std::ptr::replace(
+ schema as *mut FFI_ArrowSchema,
+ FFI_ArrowSchema::try_from(self.data_type())?,
+ )
+ };
+
+ // Don't deallocate the memory of the ArrowArray and ArrowSchema since
they are allocated in Java.
+ // They will be deallocated in JVM.
+ forget(jvm_array);
+ forget(jvm_schema);
Review Comment:
I was thinking the returned ones from `replace` is the JVM allocated objects
which I didn't think Rust can drop it. But re-thinking it, the returned ones
should be copy of the content of JVM array/schema structures. So should be safe
to drop.
--
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]