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

[GitHub] [arrow-rs] tustvold opened a new pull request, #3901: Add iterators to BooleanBuffer and NullBuffer

tustvold opened a new pull request, #3901:
URL: https://github.com/apache/arrow-rs/pull/3901

   # Which issue does this PR close?
   
   <!--
   We generally require a GitHub issue to be filed for all bug fixes and enhancements and this helps us generate change logs for our releases. You can link an issue to this PR using the GitHub syntax. For example `Closes #123` indicates that this PR will close issue #123.
   -->
   
   Part of #3880
   
   # Rationale for this change
    
   <!--
   Why are you proposing this change? If this is already explained clearly in the issue then this section is not needed.
   Explaining clearly why changes are proposed helps reviewers understand your changes and offer better suggestions for fixes.
   -->
   
   Continues to flesh out the buffer abstractions
   
   # What changes are included in this PR?
   
   <!--
   There is no need to duplicate the description in the issue here but it is sometimes worth providing a summary of the individual changes in this PR.
   -->
   
   # Are there any user-facing changes?
   
   
   <!--
   If there are user-facing changes then we may require documentation to be updated before approving the PR.
   -->
   
   <!---
   If there are any breaking changes to public APIs, please add the `breaking change` label.
   -->
   


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


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

Posted by "tustvold (via GitHub)" <gi...@apache.org>.
tustvold commented on code in PR #3901:
URL: https://github.com/apache/arrow-rs/pull/3901#discussion_r1145266905


##########
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:
   Yeah, I figured that it might avoid some confusion perhaps



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


[GitHub] [arrow-rs] tustvold merged pull request #3901: Add iterators to BooleanBuffer and NullBuffer

Posted by "tustvold (via GitHub)" <gi...@apache.org>.
tustvold merged PR #3901:
URL: https://github.com/apache/arrow-rs/pull/3901


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


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

Posted by "alamb (via GitHub)" <gi...@apache.org>.
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