Ted-Jiang commented on code in PR #3115:
URL: https://github.com/apache/arrow-rs/pull/3115#discussion_r1023591486


##########
arrow-buffer/src/buffer/immutable.rs:
##########
@@ -227,6 +227,28 @@ impl Buffer {
     pub fn count_set_bits_offset(&self, offset: usize, len: usize) -> usize {
         UnalignedBitChunk::new(self.as_slice(), offset, len).count_ones()
     }
+
+    /// Returns `MutableBuffer` for mutating the buffer if this buffer is not 
shared.
+    pub fn into_mutable(self, len: usize) -> Result<MutableBuffer, Self> {
+        let offset_ptr = self.as_ptr();
+        let offset = self.offset;
+        let length = self.length;
+        Arc::try_unwrap(self.data)
+            .map(|bytes| {
+                // The pointer of underlying buffer should not be offset.

Review Comment:
   > For the limitation, I assume that a non-zero offset means the Bytes is 
shared/sliced from others. So it is disallowed to be mutable here.
   
   Just question:  i think `Arc::try_unwrap` has check the exactly one strong 
reference.
   And all `sliced`  use the `clone()`, So this is impossible panic right?  🤔  



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