You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "jhorstmann (via GitHub)" <gi...@apache.org> on 2023/07/16 09:23:01 UTC

[GitHub] [arrow-rs] jhorstmann commented on a diff in pull request #4507: feat: `into_builder` method for BooleanArray

jhorstmann commented on code in PR #4507:
URL: https://github.com/apache/arrow-rs/pull/4507#discussion_r1264647337


##########
arrow-array/src/array/boolean_array.rs:
##########
@@ -246,6 +246,62 @@ impl BooleanArray {
         });
         Self::new(values, nulls)
     }
+
+    /// Returns `BooleanBuilder` of this boolean array for mutating its values if the underlying
+    /// data buffer is not shared by others.
+    pub fn into_builder(self) -> Result<BooleanBuilder, Self> {
+        let len = self.len();
+        let data = self.into_data();
+        let null_bit_buffer = data.nulls().map(|b| b.inner().sliced());
+
+        let buffer = data.buffers()[0].slice_with_length(data.offset(), (len + 7) / 8);

Review Comment:
   I think this would slice the buffer using byte offsets instead of bit offsets. You could look into the `Buffer::bit_slice` method or try to use `BooleanArray::slices` directly, without converting to `ArrayData` first.



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