You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "alamb (via GitHub)" <gi...@apache.org> on 2023/03/22 18:44:20 UTC

[GitHub] [arrow-rs] alamb commented on a diff in pull request #3901: Add iterators to BooleanBuffer and NullBuffer

alamb commented on code in PR #3901:
URL: https://github.com/apache/arrow-rs/pull/3901#discussion_r1145258450


##########
arrow-buffer/src/buffer/boolean.rs:
##########
@@ -164,6 +165,21 @@ impl BooleanBuffer {
     pub fn into_inner(self) -> Buffer {
         self.buffer
     }
+
+    /// Returns an iterator over the bits in this [`BooleanBuffer`]
+    pub fn iter(&self) -> BitIterator<'_> {

Review Comment:
   👌  nice



##########
arrow-buffer/src/buffer/null.rs:
##########
@@ -114,6 +114,23 @@ impl NullBuffer {
         Self::new(self.buffer.slice(offset, len))
     }
 
+    /// Returns an iterator over the bits in this [`NullBuffer`]
+    ///
+    /// Note: [`Self::valid_indices`] will be significantly faster for most use-cases
+    pub fn iter(&self) -> BitIterator<'_> {
+        self.buffer.iter()
+    }
+
+    /// Returns a [`BitIndexIterator`] over the valid indices in this [`NullBuffer`]
+    pub fn valid_indices(&self) -> BitIndexIterator<'_> {

Review Comment:
   Is the  reason this is called `valid_indices` but the equivalent is called `set_indices` in BooleanBuffer is to highlight that a "Null buffer" in arrow is really a validity buffer (`1` means non null)?



##########
arrow-buffer/src/buffer/null.rs:
##########
@@ -114,6 +114,23 @@ impl NullBuffer {
         Self::new(self.buffer.slice(offset, len))
     }
 
+    /// Returns an iterator over the bits in this [`NullBuffer`]
+    ///
+    /// Note: [`Self::valid_indices`] will be significantly faster for most use-cases
+    pub fn iter(&self) -> BitIterator<'_> {
+        self.buffer.iter()
+    }
+
+    /// Returns a [`BitIndexIterator`] over the valid indices in this [`NullBuffer`]

Review Comment:
   ```suggestion
       /// Returns a [`BitIndexIterator`] over the valid indices in this [`NullBuffer`]. 
       ///
       /// Valid indices indicate that the corresponding value is non null 
   ```



##########
arrow-buffer/src/buffer/null.rs:
##########
@@ -114,6 +114,23 @@ impl NullBuffer {
         Self::new(self.buffer.slice(offset, len))
     }
 
+    /// Returns an iterator over the bits in this [`NullBuffer`]
+    ///
+    /// Note: [`Self::valid_indices`] will be significantly faster for most use-cases
+    pub fn iter(&self) -> BitIterator<'_> {
+        self.buffer.iter()
+    }
+
+    /// Returns a [`BitIndexIterator`] over the valid indices in this [`NullBuffer`]
+    pub fn valid_indices(&self) -> BitIndexIterator<'_> {
+        self.buffer.set_indices()
+    }
+
+    /// Returns a [`BitSliceIterator`] yielding contiguous ranges of valid indices

Review Comment:
   ```suggestion
       /// Returns a [`BitSliceIterator`] yielding contiguous ranges of valid indices
       ///
       /// Valid indices indicate that the corresponding value is non null 
   ```



##########
arrow-buffer/src/buffer/null.rs:
##########
@@ -114,6 +114,23 @@ impl NullBuffer {
         Self::new(self.buffer.slice(offset, len))
     }
 
+    /// Returns an iterator over the bits in this [`NullBuffer`]

Review Comment:
   ```suggestion
       /// Returns an iterator over the bits in this [`NullBuffer`]
       ///
       /// * values of `1` indicate valid indices (the corresponding value is non null)
       /// * values of `0` indicate invalid indices (the corresponding value is null)
   ```



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