ArrowArray::try_from_raw should not assume the pointers are from Arc#1334
ArrowArray::try_from_raw should not assume the pointers are from Arc#1334sunchao merged 1 commit intoapache:masterfrom
ArrowArray::try_from_raw should not assume the pointers are from Arc#1334Conversation
Codecov Report
@@ Coverage Diff @@
## master #1334 +/- ##
=======================================
Coverage 83.03% 83.03%
=======================================
Files 181 181
Lines 52949 52951 +2
=======================================
+ Hits 43965 43968 +3
+ Misses 8984 8983 -1
Continue to review full report at Codecov.
|
|
Merged, thanks @viirya ! |
|
Thanks @sunchao ! |
| .to_string(), | ||
| )); | ||
| }; | ||
| let ffi_array = (*array).clone(); |
There was a problem hiding this comment.
I am not super familiar with this code but it makes sense to me. The clone here seems to just be a clone of the FFI_ArrowArray struct itself (which is some ints and pointers) which seems reasonable enough to me.
If someone seems performance issues from this code, we can always add a try_from_raw_arc or something, but this looks good to me for now
There was a problem hiding this comment.
The clone here seems to just be a clone of the FFI_ArrowArray struct itself (which is some ints and pointers) which seems reasonable enough to me.
That's right.
|
Guys, not sure if my understanding is right, but I think this commit will break the design and create memory leak. If we clone the FFI struct, then it means we need to free the pointer by ourself, but if we free FFI_ArrowArray, then the data in this Array will also be free? Which means we can't free the pointer(until the data are used and ready to free, but in reality we can't hold this useless pointer in a big project for such a long time), which create memory leak. As to the question @viirya raised in #1333 , when manage memory, the one who allocate it should free it, which means in our case, we need to alloc the struct in rust and pass the pointer to java and then also free the memory in rust.
|
Simply said, I don't think this is correct. That is the whole point of C data interface. The release callback is designed to be called by not only the one allocates the C data interface structure. |
As the raw pointers are converted to |
…hema (apache#1334)" This reverts commit f84c436.
Which issue does this PR close?
Closes #1333.
Rationale for this change
What changes are included in this PR?
Are there any user-facing changes?