You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2022/07/25 03:48:19 UTC

[GitHub] [arrow-rs] viirya opened a new pull request, #2157: Use ArrayAccessor in Comparison Kernels

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

   # 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.
   -->
   
   Closes #2135.
   
   # 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.
   -->
   
   # 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] viirya commented on a diff in pull request #2157: Use ArrayAccessor in Comparison Kernels

Posted by GitBox <gi...@apache.org>.
viirya commented on code in PR #2157:
URL: https://github.com/apache/arrow-rs/pull/2157#discussion_r928506171


##########
arrow/src/compute/kernels/comparison.rs:
##########
@@ -1931,177 +1804,107 @@ where
     Ok(BooleanArray::from(data))
 }
 
-macro_rules! typed_cmp {

Review Comment:
   We can remove this macro.



-- 
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 #2157: Use ArrayAccessor in Comparison Kernels

Posted by GitBox <gi...@apache.org>.
tustvold merged PR #2157:
URL: https://github.com/apache/arrow-rs/pull/2157


-- 
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 #2157: Use ArrayAccessor in Comparison Kernels

Posted by GitBox <gi...@apache.org>.
viirya commented on code in PR #2157:
URL: https://github.com/apache/arrow-rs/pull/2157#discussion_r928452024


##########
arrow/src/compute/kernels/comparison.rs:
##########
@@ -1964,6 +1838,195 @@ macro_rules! typed_cmp {
     }};
 }
 
+fn eq_typed_compares(left: &dyn Array, right: &dyn Array) -> Result<BooleanArray> {
+    match (left.data_type(), left.data_type()) {
+        (DataType::Boolean, DataType::Boolean) => compare_op(
+            left.as_any().downcast_ref::<BooleanArray>().unwrap(),
+            right.as_any().downcast_ref::<BooleanArray>().unwrap(),
+            |a, b| !(a ^ b),
+        ),
+        (DataType::Int8, DataType::Int8) => compare_op(
+            left.as_any().downcast_ref::<Int8Array>().unwrap(),
+            right.as_any().downcast_ref::<Int8Array>().unwrap(),
+            |a, b| a == b,
+        ),

Review Comment:
   But for some macros which we match array types, seems it doesn't reduce too much duplication, as we still need to match particular array type (which implements ArrayAccessor).



-- 
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 #2157: Use ArrayAccessor in Comparison Kernels

Posted by GitBox <gi...@apache.org>.
viirya commented on code in PR #2157:
URL: https://github.com/apache/arrow-rs/pull/2157#discussion_r928452024


##########
arrow/src/compute/kernels/comparison.rs:
##########
@@ -1964,6 +1838,195 @@ macro_rules! typed_cmp {
     }};
 }
 
+fn eq_typed_compares(left: &dyn Array, right: &dyn Array) -> Result<BooleanArray> {
+    match (left.data_type(), left.data_type()) {
+        (DataType::Boolean, DataType::Boolean) => compare_op(
+            left.as_any().downcast_ref::<BooleanArray>().unwrap(),
+            right.as_any().downcast_ref::<BooleanArray>().unwrap(),
+            |a, b| !(a ^ b),
+        ),
+        (DataType::Int8, DataType::Int8) => compare_op(
+            left.as_any().downcast_ref::<Int8Array>().unwrap(),
+            right.as_any().downcast_ref::<Int8Array>().unwrap(),
+            |a, b| a == b,
+        ),

Review Comment:
   But for some macros which we match array types, seems it doesn't reduce too much duplication.



-- 
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] codecov-commenter commented on pull request #2157: Use ArrayAccessor in Comparison Kernels

Posted by GitBox <gi...@apache.org>.
codecov-commenter commented on PR #2157:
URL: https://github.com/apache/arrow-rs/pull/2157#issuecomment-1193562609

   # [Codecov](https://codecov.io/gh/apache/arrow-rs/pull/2157?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
   > Merging [#2157](https://codecov.io/gh/apache/arrow-rs/pull/2157?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (037a99d) into [master](https://codecov.io/gh/apache/arrow-rs/commit/19a71899d828f1c6204c97542645fd801a848ceb?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (19a7189) will **decrease** coverage by `0.09%`.
   > The diff coverage is `57.61%`.
   
   ```diff
   @@            Coverage Diff             @@
   ##           master    #2157      +/-   ##
   ==========================================
   - Coverage   82.86%   82.76%   -0.10%     
   ==========================================
     Files         237      237              
     Lines       61296    61510     +214     
   ==========================================
   + Hits        50792    50911     +119     
   - Misses      10504    10599      +95     
   ```
   
   
   | [Impacted Files](https://codecov.io/gh/apache/arrow-rs/pull/2157?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
   |---|---|---|
   | [arrow/src/compute/kernels/comparison.rs](https://codecov.io/gh/apache/arrow-rs/pull/2157/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-YXJyb3cvc3JjL2NvbXB1dGUva2VybmVscy9jb21wYXJpc29uLnJz) | `90.01% <57.61%> (-2.58%)` | :arrow_down: |
   | [arrow/src/array/iterator.rs](https://codecov.io/gh/apache/arrow-rs/pull/2157/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-YXJyb3cvc3JjL2FycmF5L2l0ZXJhdG9yLnJz) | `86.45% <0.00%> (-13.55%)` | :arrow_down: |
   | [parquet/src/column/reader/decoder.rs](https://codecov.io/gh/apache/arrow-rs/pull/2157/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGFycXVldC9zcmMvY29sdW1uL3JlYWRlci9kZWNvZGVyLnJz) | `50.00% <0.00%> (-11.34%)` | :arrow_down: |
   | [arrow/src/util/decimal.rs](https://codecov.io/gh/apache/arrow-rs/pull/2157/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-YXJyb3cvc3JjL3V0aWwvZGVjaW1hbC5ycw==) | `86.92% <0.00%> (-4.59%)` | :arrow_down: |
   | [...row/src/array/builder/string\_dictionary\_builder.rs](https://codecov.io/gh/apache/arrow-rs/pull/2157/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-YXJyb3cvc3JjL2FycmF5L2J1aWxkZXIvc3RyaW5nX2RpY3Rpb25hcnlfYnVpbGRlci5ycw==) | `90.64% <0.00%> (-0.72%)` | :arrow_down: |
   | [arrow/src/array/array\_decimal.rs](https://codecov.io/gh/apache/arrow-rs/pull/2157/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-YXJyb3cvc3JjL2FycmF5L2FycmF5X2RlY2ltYWwucnM=) | `90.32% <0.00%> (-0.72%)` | :arrow_down: |
   | [parquet/src/encodings/encoding.rs](https://codecov.io/gh/apache/arrow-rs/pull/2157/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGFycXVldC9zcmMvZW5jb2RpbmdzL2VuY29kaW5nLnJz) | `93.43% <0.00%> (-0.20%)` | :arrow_down: |
   | [arrow/src/array/array\_binary.rs](https://codecov.io/gh/apache/arrow-rs/pull/2157/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-YXJyb3cvc3JjL2FycmF5L2FycmF5X2JpbmFyeS5ycw==) | `92.87% <0.00%> (ø)` | |
   | [parquet\_derive/src/parquet\_field.rs](https://codecov.io/gh/apache/arrow-rs/pull/2157/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGFycXVldF9kZXJpdmUvc3JjL3BhcnF1ZXRfZmllbGQucnM=) | `65.98% <0.00%> (+0.22%)` | :arrow_up: |
   | [arrow/src/datatypes/datatype.rs](https://codecov.io/gh/apache/arrow-rs/pull/2157/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-YXJyb3cvc3JjL2RhdGF0eXBlcy9kYXRhdHlwZS5ycw==) | `63.00% <0.00%> (+0.31%)` | :arrow_up: |
   | ... and [2 more](https://codecov.io/gh/apache/arrow-rs/pull/2157/diff?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | |
   
   Help us with your feedback. Take ten seconds to tell us [how you rate us](https://about.codecov.io/nps?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
   


-- 
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 pull request #2157: Use ArrayAccessor in Comparison Kernels

Posted by GitBox <gi...@apache.org>.
viirya commented on PR #2157:
URL: https://github.com/apache/arrow-rs/pull/2157#issuecomment-1193667512

   `cargo bench --bench comparison_kernels -- --baseline master` doesn't see regression.


-- 
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] ursabot commented on pull request #2157: Use ArrayAccessor in Comparison Kernels

Posted by GitBox <gi...@apache.org>.
ursabot commented on PR #2157:
URL: https://github.com/apache/arrow-rs/pull/2157#issuecomment-1194192737

   Benchmark runs are scheduled for baseline = e68852c8a9c08da2d1e4857c0e811bd0f687f7c5 and contender = 4a47ab78b98b8b0c95d27bee3f468421757b85cd. 4a47ab78b98b8b0c95d27bee3f468421757b85cd is a master commit associated with this PR. Results will be available as each benchmark for each run completes.
   Conbench compare runs links:
   [Skipped :warning: Benchmarking of arrow-rs-commits is not supported on ec2-t3-xlarge-us-east-2] [ec2-t3-xlarge-us-east-2](https://conbench.ursa.dev/compare/runs/c2ee3db5ab5f4928bb3ec1c150675c65...11f1810525ba45b588671538674b9946/)
   [Skipped :warning: Benchmarking of arrow-rs-commits is not supported on test-mac-arm] [test-mac-arm](https://conbench.ursa.dev/compare/runs/04eca367cf2246d29890738841bf2ee4...5089e1878cdb4e089a80ad186f7a90f7/)
   [Skipped :warning: Benchmarking of arrow-rs-commits is not supported on ursa-i9-9960x] [ursa-i9-9960x](https://conbench.ursa.dev/compare/runs/767446a5baab420e8fabede8fe2638c1...13466615317c481c8dbeaccb074eda90/)
   [Skipped :warning: Benchmarking of arrow-rs-commits is not supported on ursa-thinkcentre-m75q] [ursa-thinkcentre-m75q](https://conbench.ursa.dev/compare/runs/523426a05a3c4e2392ebbe321de059d0...369ac9176c7e4bc186469a61281ac5be/)
   Buildkite builds:
   Supported benchmarks:
   ec2-t3-xlarge-us-east-2: Supported benchmark langs: Python, R. Runs only benchmarks with cloud = True
   test-mac-arm: Supported benchmark langs: C++, Python, R
   ursa-i9-9960x: Supported benchmark langs: Python, R, JavaScript
   ursa-thinkcentre-m75q: Supported benchmark langs: C++, Java
   


-- 
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 pull request #2157: Use ArrayAccessor in Comparison Kernels

Posted by GitBox <gi...@apache.org>.
viirya commented on PR #2157:
URL: https://github.com/apache/arrow-rs/pull/2157#issuecomment-1194308666

   Thanks @jhorstmann @alamb @tustvold 


-- 
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] jhorstmann commented on pull request #2157: Use ArrayAccessor in Comparison Kernels

Posted by GitBox <gi...@apache.org>.
jhorstmann commented on PR #2157:
URL: https://github.com/apache/arrow-rs/pull/2157#issuecomment-1193788202

   Nice improvement!


-- 
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 #2157: Use ArrayAccessor in Comparison Kernels

Posted by GitBox <gi...@apache.org>.
viirya commented on code in PR #2157:
URL: https://github.com/apache/arrow-rs/pull/2157#discussion_r928451736


##########
arrow/src/compute/kernels/comparison.rs:
##########
@@ -40,168 +39,72 @@ use regex::{escape, Regex};
 use std::any::type_name;
 use std::collections::HashMap;
 
-/// Helper function to perform boolean lambda function on values from two arrays, this
+/// Helper function to perform boolean lambda function on values from two array accessors, this
 /// version does not attempt to use SIMD.
-macro_rules! compare_op {
-    ($left: expr, $right:expr, $op:expr) => {{
-        if $left.len() != $right.len() {
-            return Err(ArrowError::ComputeError(
-                "Cannot perform comparison operation on arrays of different length"
-                    .to_string(),
-            ));
-        }
-
-        let null_bit_buffer =
-            combine_option_bitmap(&[$left.data_ref(), $right.data_ref()], $left.len())?;
-
-        // Safety:
-        // `i < $left.len()` and $left.len() == $right.len()
-        let comparison = (0..$left.len())
-            .map(|i| unsafe { $op($left.value_unchecked(i), $right.value_unchecked(i)) });
-        // same size as $left.len() and $right.len()
-        let buffer = unsafe { MutableBuffer::from_trusted_len_iter_bool(comparison) };
-
-        let data = unsafe {
-            ArrayData::new_unchecked(
-                DataType::Boolean,
-                $left.len(),
-                None,
-                null_bit_buffer,
-                0,
-                vec![Buffer::from(buffer)],
-                vec![],
-            )
-        };
-        Ok(BooleanArray::from(data))
-    }};
-}
+fn compare_op<T: ArrayAccessor, F>(left: T, right: T, op: F) -> Result<BooleanArray>

Review Comment:
   `ArrayAccessor` allows us to replace macro with generic function like this.



-- 
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 #2157: Use ArrayAccessor in Comparison Kernels

Posted by GitBox <gi...@apache.org>.
viirya commented on code in PR #2157:
URL: https://github.com/apache/arrow-rs/pull/2157#discussion_r928506171


##########
arrow/src/compute/kernels/comparison.rs:
##########
@@ -1931,177 +1804,107 @@ where
     Ok(BooleanArray::from(data))
 }
 
-macro_rules! typed_cmp {

Review Comment:
   We can remove this macro.



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