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/08/19 22:15:19 UTC

[GitHub] [arrow-rs] viirya opened a new pull request, #2533: Compare dictionary with primitive array in `eq_dyn` and `neq_dyn`

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

   # 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 #.
   
   # 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] tustvold commented on a diff in pull request #2533: Compare dictionary with primitive array in `eq_dyn` and `neq_dyn`

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


##########
arrow/src/compute/kernels/comparison.rs:
##########
@@ -2173,45 +2270,28 @@ macro_rules! typed_dict_compares {
     }};
 }
 
-/// Helper function to perform boolean lambda function on values from two dictionary arrays, this
-/// version does not attempt to use SIMD explicitly (though the compiler may auto vectorize)
-fn compare_dict_op<'a, K, V, F>(
-    left: TypedDictionaryArray<'a, K, V>,
-    right: TypedDictionaryArray<'a, K, V>,
+/// Perform given operation on `DictionaryArray` and `PrimitiveArray`. The value
+/// type of `DictionaryArray` is same as `PrimitiveArray`'s type.
+fn cmp_dict_primitive<K, T, F>(
+    left: &DictionaryArray<K>,
+    right: &dyn Array,
     op: F,
 ) -> Result<BooleanArray>
 where
     K: ArrowNumericType,
-    V: Sync + Send,
-    &'a V: ArrayAccessor,
-    F: Fn(<&V as ArrayAccessor>::Item, <&V as ArrayAccessor>::Item) -> bool,
+    T: ArrowNumericType + Sync + Send,
+    F: Fn(T::Native, T::Native) -> bool,
 {
-    if left.len() != right.len() {
-        return Err(ArrowError::ComputeError(
-            "Cannot perform comparison operation on arrays of different length"
-                .to_string(),
-        ));
-    }
-
-    let left_iter = left.into_iter();
-    let right_iter = right.into_iter();
-
-    let result = left_iter

Review Comment:
   No, because that will panic... I'm working on a fix - standby



-- 
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 #2533: Compare dictionary with primitive array in `eq_dyn` and `neq_dyn`

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

   Benchmark runs are scheduled for baseline = 4949a3d026bc15dd8320063d9e06fe048d26c6e8 and contender = 1d5656eb023921821bdf2204b208e418ebbfc034. 1d5656eb023921821bdf2204b208e418ebbfc034 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/2c327113dc06441591df67644e545916...211e16ab1b2946ff8d821090a34b7c60/)
   [Skipped :warning: Benchmarking of arrow-rs-commits is not supported on test-mac-arm] [test-mac-arm](https://conbench.ursa.dev/compare/runs/2c7c3cead21e45ad91b898772d1bfed1...5ac947296d9f42178db28fd6354cbdfa/)
   [Skipped :warning: Benchmarking of arrow-rs-commits is not supported on ursa-i9-9960x] [ursa-i9-9960x](https://conbench.ursa.dev/compare/runs/71487c71ccdb4a2c92bf91822786bee9...f5247f73d7f44e2398e3c3b80d0e9b47/)
   [Skipped :warning: Benchmarking of arrow-rs-commits is not supported on ursa-thinkcentre-m75q] [ursa-thinkcentre-m75q](https://conbench.ursa.dev/compare/runs/010ad822c3c74a569b1b6fd0160f9e43...73e60d55e13b49268f84b90e6372c5aa/)
   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 a diff in pull request #2533: Compare dictionary with primitive array in `eq_dyn` and `neq_dyn`

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


##########
arrow/src/compute/kernels/comparison.rs:
##########
@@ -2173,45 +2270,28 @@ macro_rules! typed_dict_compares {
     }};
 }
 
-/// Helper function to perform boolean lambda function on values from two dictionary arrays, this
-/// version does not attempt to use SIMD explicitly (though the compiler may auto vectorize)
-fn compare_dict_op<'a, K, V, F>(

Review Comment:
   As `TypedDictionaryArray` implements `ArrayAccessor` too, we can use `compare_op` to replace this `compare_dict_op`. So removing it here.



-- 
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 #2533: Compare dictionary with primitive array in `eq_dyn` and `neq_dyn`

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


##########
arrow/src/compute/kernels/comparison.rs:
##########
@@ -2173,45 +2270,28 @@ macro_rules! typed_dict_compares {
     }};
 }
 
-/// Helper function to perform boolean lambda function on values from two dictionary arrays, this
-/// version does not attempt to use SIMD explicitly (though the compiler may auto vectorize)
-fn compare_dict_op<'a, K, V, F>(
-    left: TypedDictionaryArray<'a, K, V>,
-    right: TypedDictionaryArray<'a, K, V>,
+/// Perform given operation on `DictionaryArray` and `PrimitiveArray`. The value
+/// type of `DictionaryArray` is same as `PrimitiveArray`'s type.
+fn cmp_dict_primitive<K, T, F>(
+    left: &DictionaryArray<K>,
+    right: &dyn Array,
     op: F,
 ) -> Result<BooleanArray>
 where
     K: ArrowNumericType,
-    V: Sync + Send,
-    &'a V: ArrayAccessor,
-    F: Fn(<&V as ArrayAccessor>::Item, <&V as ArrayAccessor>::Item) -> bool,
+    T: ArrowNumericType + Sync + Send,
+    F: Fn(T::Native, T::Native) -> bool,
 {
-    if left.len() != right.len() {
-        return Err(ArrowError::ComputeError(
-            "Cannot perform comparison operation on arrays of different length"
-                .to_string(),
-        ));
-    }
-
-    let left_iter = left.into_iter();
-    let right_iter = right.into_iter();
-
-    let result = left_iter

Review Comment:
   Should we just call `self.values.value` instead of `value_unchecked` in `ArrayAccessor.value_unchecked` of `TypedDictionaryArray`? It might be less performance, though.



-- 
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 #2533: Compare dictionary with primitive array in `eq_dyn` and `neq_dyn`

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


##########
arrow/src/compute/kernels/comparison.rs:
##########
@@ -2173,45 +2270,28 @@ macro_rules! typed_dict_compares {
     }};
 }
 
-/// Helper function to perform boolean lambda function on values from two dictionary arrays, this
-/// version does not attempt to use SIMD explicitly (though the compiler may auto vectorize)
-fn compare_dict_op<'a, K, V, F>(
-    left: TypedDictionaryArray<'a, K, V>,
-    right: TypedDictionaryArray<'a, K, V>,
+/// Perform given operation on `DictionaryArray` and `PrimitiveArray`. The value
+/// type of `DictionaryArray` is same as `PrimitiveArray`'s type.
+fn cmp_dict_primitive<K, T, F>(
+    left: &DictionaryArray<K>,
+    right: &dyn Array,
     op: F,
 ) -> Result<BooleanArray>
 where
     K: ArrowNumericType,
-    V: Sync + Send,
-    &'a V: ArrayAccessor,
-    F: Fn(<&V as ArrayAccessor>::Item, <&V as ArrayAccessor>::Item) -> bool,
+    T: ArrowNumericType + Sync + Send,
+    F: Fn(T::Native, T::Native) -> bool,
 {
-    if left.len() != right.len() {
-        return Err(ArrowError::ComputeError(
-            "Cannot perform comparison operation on arrays of different length"
-                .to_string(),
-        ));
-    }
-
-    let left_iter = left.into_iter();
-    let right_iter = right.into_iter();
-
-    let result = left_iter

Review Comment:
   As pointed out by @pvsri https://github.com/apache/arrow-rs/issues/2564#issuecomment-1225867873 this change introduces unsoundness, as dictionary indexes aren't always valid. I will have a think about how best to handle 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 merged pull request #2533: Compare dictionary with primitive array in `eq_dyn` and `neq_dyn`

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


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