Kontinuation commented on code in PR #905: URL: https://github.com/apache/datafusion-comet/pull/905#discussion_r1743702560
########## 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'm not familiar with Rust, I'm not sure if `to_ffi` + `replace` could cleanly do the trick. -- 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: github-unsubscr...@datafusion.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org For additional commands, e-mail: github-h...@datafusion.apache.org