Kontinuation commented on code in PR #905:
URL: https://github.com/apache/datafusion-comet/pull/905#discussion_r1744699978
##########
native/core/src/execution/utils.rs:
##########
@@ -96,6 +99,22 @@ 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())?,
+ )
+ };
+
+ std::mem::forget(jvm_array);
+ std::mem::forget(jvm_schema);
Review Comment:
If the base structures allocated by JVM cannot be safely dropped, we may use
`std::ptr::write(array as *mut FFI_ArrowArray, FFI_ArrowArray::new(self))` to
simply overwrite the base structure, without moving out the original structure.
--
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]