viirya commented on a change in pull request #1432:
URL: https://github.com/apache/arrow-rs/pull/1432#discussion_r827577920



##########
File path: arrow/src/array/array.rs
##########
@@ -629,7 +629,9 @@ pub unsafe fn make_array_from_raw(
     schema: *const ffi::FFI_ArrowSchema,
 ) -> Result<ArrayRef> {
     let array = ffi::ArrowArray::try_from_raw(array, schema)?;
-    let data = ArrayData::try_from(array)?;
+    let data = ArrayData::try_from(&array)?;
+    // Avoid dropping the `Box` pointers and trigger the `release` mechanism.
+    let _ = ffi::ArrowArray::into_raw(array);

Review comment:
       I've tried it. It seems okay. `Arc::from` previously not work, I think, 
is because it calls allocator to deallocate the memory allocation. As it is 
allocated by Java in our case, we cannot let Rust to deallocate it.
   
   `std::ptr::drop_in_place` seems only trigger dropping. As we make it as 
empty structs, it won't trigger `release`. I think this is close to #1436 which 
cleans up `release` field of source structs after cloning it. Here we in fact 
still clone it, but just internally and don't expose `clone`.
   
   Looks good to me. Thanks @sunchao . 
   
   cc @alamb @wangfenjin WDYT? Are you agreed with this approach?




-- 
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]


Reply via email to