John-W-Lewis commented on issue #1142:
URL: https://github.com/apache/arrow-java/issues/1142#issuecomment-4476266198

   Following up on PR #1145: while that fix correctly addresses the safety 
issue (by using `TransferPair.transfer()`), I've since realised it changes the 
semantics -- the source root is emptied after the operation, whereas the 
original (unsafe) implementation allowed both source and result to read the 
same data.
   
   I've developed a better approach using a new `VectorOps` utility that 
provides a `shareCopy` operation: this creates a new vector sharing the same 
underlying allocations via reference counting. Both source and result remain 
fully usable, and the memory is only released when all sharing vectors/roots 
have been closed.
   
   This gives us the best of both worlds: safe (proper reference counting) 
*and* preserves the original intended semantics.
   
   I'll be opening a new PR with this approach and closing #1145 in its favour.


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