Rich-T-kid commented on code in PR #10976:
URL: https://github.com/apache/arrow-rs/pull/10976#discussion_r3927980261


##########
arrow-buffer/src/buffer/null.rs:
##########
@@ -142,14 +142,53 @@ impl NullBuffer {
             .ok_or_else(|| OverflowError::new::<usize>("buffer length"))?;
         let mut buffer = MutableBuffer::new_null(capacity);
 
-        // Expand each bit within `null_mask` into `element_len`
-        // bits, constructing the implicit mask of the child elements
-        for i in 0..self.buffer.len() {
-            if self.is_null(i) {
-                continue;
+        if count % 8 == 0 {
+            // When count is a multiple of 8 every expanded run starts on a 
byte
+            // boundary (bit i starts at bit i*count, which is divisible by 8),
+            // so we can fill count/8 bytes of 0xFF at a time instead of 
setting
+            // bits individually.
+            //
+            // By iterating over contiguous runs of valid bits rather than
+            // individual bits, a dense validity buffer (long runs of non-null
+            // values) collapses into a single fill call per run.

Review Comment:
   remove



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