You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2022/12/20 09:45:53 UTC

[GitHub] [arrow-rs] tustvold commented on a diff in pull request #3326: Provide `into_builder` for bytearray

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


##########
arrow-array/src/builder/generic_bytes_builder.rs:
##########
@@ -118,10 +142,39 @@ impl<T: ByteArrayType> GenericByteBuilder<T> {
         self.value_builder.as_slice()
     }
 
+    /// Returns the current values buffer as a mutable slice
+    pub fn values_slice_mut(&mut self) -> &mut [u8] {
+        self.value_builder.as_slice_mut()
+    }
+
     /// Returns the current offsets buffer as a slice
     pub fn offsets_slice(&self) -> &[T::Offset] {
         self.offsets_builder.as_slice()
     }
+
+    /// Returns the current offsets buffer as a mutable slice
+    pub fn offsets_slice_mut(&mut self) -> &mut [T::Offset] {

Review Comment:
   I think this would allow you to mutate the contents such that the offsets are no longer valid, potentially leading to UB



##########
arrow-array/src/builder/generic_bytes_builder.rs:
##########
@@ -53,6 +53,30 @@ impl<T: ByteArrayType> GenericByteBuilder<T> {
         }
     }
 
+    /// Creates a new primitive array builder from buffers

Review Comment:
   This comment needs updating



##########
arrow-array/src/builder/generic_bytes_builder.rs:
##########
@@ -53,6 +53,30 @@ impl<T: ByteArrayType> GenericByteBuilder<T> {
         }
     }
 
+    /// Creates a new primitive array builder from buffers
+    pub fn new_from_buffer(

Review Comment:
   This method needs to be unsafe as it doesn't verify the buffer contents



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org