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/21 17:47:31 UTC

[GitHub] [arrow-rs] tustvold opened a new pull request, #3895: Use BooleanBuffer in BooleanArray (#3879)

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

   # 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 #3879
   
   # 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 the process of making arrays wrappers around strongly typed 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?
   
   Yes, it changes the return type of `BooleanArray::values`. I opted to just break this API instead of deprecating, as I wanted to keep the name the same, and the method is rarely used in downstreams, DataFusion doesn't call it at all, likely because it is hard to use correctly (something this PR improves).
   
   <!--
   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] viirya commented on a diff in pull request #3895: Use BooleanBuffer in BooleanArray (#3879)

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


##########
arrow-array/src/array/boolean_array.rs:
##########
@@ -96,19 +96,19 @@ impl BooleanArray {
         BooleanBuilder::with_capacity(capacity)
     }
 
-    /// Returns a `Buffer` holding all the values of this array.
+    /// Returns the underlying [`BooleanBuffer`] holding all the values of this array.
     ///
     /// Note this doesn't take the offset of this array into account.

Review Comment:
   > Note this doesn't take the offset of this array into account.
   
   This is still true?



-- 
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 #3895: Use BooleanBuffer in BooleanArray (#3879)

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


##########
arrow-array/src/array/boolean_array.rs:
##########
@@ -96,19 +96,19 @@ impl BooleanArray {
         BooleanBuilder::with_capacity(capacity)
     }
 
-    /// Returns a `Buffer` holding all the values of this array.
+    /// Returns the underlying [`BooleanBuffer`] holding all the values of this array.
     ///
     /// Note this doesn't take the offset of this array into account.

Review Comment:
   Good spot, whilst technically still true, it is rather misleading



##########
arrow-array/src/array/boolean_array.rs:
##########
@@ -96,19 +96,19 @@ impl BooleanArray {
         BooleanBuilder::with_capacity(capacity)
     }
 
-    /// Returns a `Buffer` holding all the values of this array.
+    /// Returns the underlying [`BooleanBuffer`] holding all the values of this array.
     ///
     /// Note this doesn't take the offset of this array into account.

Review Comment:
   Good spot, whilst technically still true, it is rather misleading will 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: 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 #3895: Use BooleanBuffer in BooleanArray (#3879)

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


##########
arrow-select/src/filter.rs:
##########
@@ -154,15 +152,12 @@ pub fn build_filter(filter: &BooleanArray) -> Result<Filter, ArrowError> {
 pub fn prep_null_mask_filter(filter: &BooleanArray) -> BooleanArray {
     let array_data = filter.data_ref();
     let nulls = array_data.nulls().unwrap();
-    let mask = filter.values();
-    let offset = filter.offset();
-
-    let new_mask =
-        buffer_bin_and(mask, offset, nulls.buffer(), nulls.offset(), filter.len());
+    let mask = filter.values() & nulls.inner();
 
     let array_data = ArrayData::builder(DataType::Boolean)
-        .len(filter.len())
-        .add_buffer(new_mask);
+        .len(mask.len())

Review Comment:
   A follow up PR will add a `BooleanArray::new` method



##########
arrow-select/src/filter.rs:
##########
@@ -154,15 +152,12 @@ pub fn build_filter(filter: &BooleanArray) -> Result<Filter, ArrowError> {
 pub fn prep_null_mask_filter(filter: &BooleanArray) -> BooleanArray {
     let array_data = filter.data_ref();
     let nulls = array_data.nulls().unwrap();
-    let mask = filter.values();
-    let offset = filter.offset();
-
-    let new_mask =
-        buffer_bin_and(mask, offset, nulls.buffer(), nulls.offset(), filter.len());
+    let mask = filter.values() & nulls.inner();
 
     let array_data = ArrayData::builder(DataType::Boolean)
-        .len(filter.len())
-        .add_buffer(new_mask);
+        .len(mask.len())

Review Comment:
   A follow up PR will add a `BooleanArray::new` method to encapsulate this logic



-- 
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 pull request #3895: Use BooleanBuffer in BooleanArray (#3879)

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

   I'm running into some issues converting `PrimitiveArray::values` to return `ScalarBuffer<T>` instead of `&[T]` so I may need to change plan to instead add a `values_buffer` method to the arrays, will sleep on it


-- 
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 #3895: Use BooleanBuffer in BooleanArray (#3879)

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


##########
arrow-ord/src/comparison.rs:
##########
@@ -196,23 +195,19 @@ pub fn eq_bool_scalar(
     left: &BooleanArray,
     right: bool,
 ) -> Result<BooleanArray, ArrowError> {
-    let len = left.len();
-    let left_offset = left.offset();
-
-    let values = if right {
-        left.values().bit_slice(left_offset, len)
-    } else {
-        buffer_unary_not(left.values(), left.offset(), left.len())
+    let values = match right {
+        true => left.values().clone(),
+        false => !left.values(),

Review Comment:
   that is fancy 👍 



-- 
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 #3895: Use BooleanBuffer in BooleanArray (#3879)

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


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