tustvold commented on code in PR #3115:
URL: https://github.com/apache/arrow-rs/pull/3115#discussion_r1023328483


##########
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:
   Yeah ideally we'd do something like make MutableArray hold a Bytes, and then 
push an offset into Bytes. We could even extend the Allocation trait to allow 
reallocation of custom allocated data. Not sure how much, if any, of that you 
would be interested in doing 😅 was more just an observation



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