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/11/02 23:13:52 UTC

[GitHub] [arrow-rs] viirya opened a new pull request, #3007: Add macro downcast_temporal_array

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

   # 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.
   -->
   
   This should be useful for temporal kernels.
   
   # 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 #3007: Add macro downcast_temporal_array

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


##########
arrow-array/src/cast.rs:
##########
@@ -98,52 +98,35 @@ macro_rules! downcast_integer {
 /// `m` with the corresponding [`ArrowPrimitiveType`], followed by any additional arguments
 ///
 /// ```
-/// # use arrow_array::{downcast_primitive, ArrowPrimitiveType};
+/// # use arrow_array::{downcast_temporal, ArrowPrimitiveType};
 /// # use arrow_schema::DataType;
 ///
-/// macro_rules! primitive_size_helper {
+/// macro_rules! temporal_size_helper {
 ///   ($t:ty, $o:ty) => {
 ///       std::mem::size_of::<<$t as ArrowPrimitiveType>::Native>() as $o
 ///   };
 /// }
 ///
-/// fn primitive_size(t: &DataType) -> u8 {
-///     downcast_primitive! {
-///         t => (primitive_size_helper, u8),
+/// fn temporal_size(t: &DataType) -> u8 {
+///     downcast_temporal! {
+///         t => (temporal_size_helper, u8),
 ///         _ => u8::MAX
 ///     }
 /// }
 ///
-/// assert_eq!(primitive_size(&DataType::Int32), 4);
-/// assert_eq!(primitive_size(&DataType::Int64), 8);
-/// assert_eq!(primitive_size(&DataType::Float16), 2);
+/// assert_eq!(temporal_size(&DataType::Date32), 4);
+/// assert_eq!(temporal_size(&DataType::Date64), 8);
 /// ```
 ///
 /// [`DataType`]: arrow_schema::DataType
 #[macro_export]
-macro_rules! downcast_primitive {
+macro_rules! downcast_temporal {
     ($($data_type:expr),+ => ($m:path $(, $args:tt)*), $($($p:pat),+ => $fallback:expr $(,)*)*) => {
-        $crate::downcast_integer! {
-            $($data_type),+ => ($m $(, $args)*),
-            $crate::repeat_pat!(arrow_schema::DataType::Float16, $($data_type),+) => {
-                $m!($crate::types::Float16Type $(, $args)*)
-            }
-            $crate::repeat_pat!(arrow_schema::DataType::Float32, $($data_type),+) => {
-                $m!($crate::types::Float32Type $(, $args)*)
-            }
-            $crate::repeat_pat!(arrow_schema::DataType::Float64, $($data_type),+) => {
-                $m!($crate::types::Float64Type $(, $args)*)
-            }
-            $crate::repeat_pat!(arrow_schema::DataType::Date32, $($data_type),+) => {
-                $m!($crate::types::Date32Type $(, $args)*)
-            }
-            $crate::repeat_pat!(arrow_schema::DataType::Date64, $($data_type),+) => {
-                $m!($crate::types::Date64Type $(, $args)*)
-            }
+        match ($($data_type),+) {
             $crate::repeat_pat!(arrow_schema::DataType::Time32(arrow_schema::TimeUnit::Second), $($data_type),+) => {
                 $m!($crate::types::Time32SecondType $(, $args)*)
             }
-            $crate::repeat_pat!(arrow_schema::DataType::Time32(arrow_schema::TimeUnit::Millisecond), $($data_type),+) => {
+            $crate::repeat_pat!(arrow_schema::DataType::Time32(arrow_schema::TimeUnit::Microsecond), $($data_type),+) => {

Review Comment:
   Actually there is a typo 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] tustvold merged pull request #3007: Add macro downcast_temporal_array

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


-- 
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 #3007: Add macro downcast_temporal_array

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

   Benchmark runs are scheduled for baseline = a2c6647d4790b64c538361d02bdbe34640ee75d2 and contender = 24afac49063d4ee92c0a2be84fd7c305d6088e14. 24afac49063d4ee92c0a2be84fd7c305d6088e14 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/cb450295c181414dad329eea77b378d6...dd71a850fca84c07aae7d3827d3dec02/)
   [Skipped :warning: Benchmarking of arrow-rs-commits is not supported on test-mac-arm] [test-mac-arm](https://conbench.ursa.dev/compare/runs/f1c13ec8eccf4b4fbc5426d09190f603...4769bd6f399f4b8d9c3b290de59601f4/)
   [Skipped :warning: Benchmarking of arrow-rs-commits is not supported on ursa-i9-9960x] [ursa-i9-9960x](https://conbench.ursa.dev/compare/runs/0450c66d48a74d11a70a98dc8c2c72b8...d849acddbe544ce8bf58a51c4247f920/)
   [Skipped :warning: Benchmarking of arrow-rs-commits is not supported on ursa-thinkcentre-m75q] [ursa-thinkcentre-m75q](https://conbench.ursa.dev/compare/runs/7bf8bb6dba3a450aa13bbb69b940cb7f...83ce5af0e4d842e0b2a4f3d54313d21a/)
   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 #3007: Add macro downcast_temporal_array

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


##########
arrow-array/src/cast.rs:
##########
@@ -98,52 +98,35 @@ macro_rules! downcast_integer {
 /// `m` with the corresponding [`ArrowPrimitiveType`], followed by any additional arguments
 ///
 /// ```
-/// # use arrow_array::{downcast_primitive, ArrowPrimitiveType};
+/// # use arrow_array::{downcast_temporal, ArrowPrimitiveType};
 /// # use arrow_schema::DataType;
 ///
-/// macro_rules! primitive_size_helper {
+/// macro_rules! temporal_size_helper {
 ///   ($t:ty, $o:ty) => {
 ///       std::mem::size_of::<<$t as ArrowPrimitiveType>::Native>() as $o
 ///   };
 /// }
 ///
-/// fn primitive_size(t: &DataType) -> u8 {
-///     downcast_primitive! {
-///         t => (primitive_size_helper, u8),
+/// fn temporal_size(t: &DataType) -> u8 {
+///     downcast_temporal! {
+///         t => (temporal_size_helper, u8),
 ///         _ => u8::MAX
 ///     }
 /// }
 ///
-/// assert_eq!(primitive_size(&DataType::Int32), 4);
-/// assert_eq!(primitive_size(&DataType::Int64), 8);
-/// assert_eq!(primitive_size(&DataType::Float16), 2);
+/// assert_eq!(temporal_size(&DataType::Date32), 4);
+/// assert_eq!(temporal_size(&DataType::Date64), 8);
 /// ```
 ///
 /// [`DataType`]: arrow_schema::DataType
 #[macro_export]
-macro_rules! downcast_primitive {
+macro_rules! downcast_temporal {
     ($($data_type:expr),+ => ($m:path $(, $args:tt)*), $($($p:pat),+ => $fallback:expr $(,)*)*) => {
-        $crate::downcast_integer! {
-            $($data_type),+ => ($m $(, $args)*),
-            $crate::repeat_pat!(arrow_schema::DataType::Float16, $($data_type),+) => {
-                $m!($crate::types::Float16Type $(, $args)*)
-            }
-            $crate::repeat_pat!(arrow_schema::DataType::Float32, $($data_type),+) => {
-                $m!($crate::types::Float32Type $(, $args)*)
-            }
-            $crate::repeat_pat!(arrow_schema::DataType::Float64, $($data_type),+) => {
-                $m!($crate::types::Float64Type $(, $args)*)
-            }
-            $crate::repeat_pat!(arrow_schema::DataType::Date32, $($data_type),+) => {
-                $m!($crate::types::Date32Type $(, $args)*)
-            }
-            $crate::repeat_pat!(arrow_schema::DataType::Date64, $($data_type),+) => {
-                $m!($crate::types::Date64Type $(, $args)*)
-            }
+        match ($($data_type),+) {
             $crate::repeat_pat!(arrow_schema::DataType::Time32(arrow_schema::TimeUnit::Second), $($data_type),+) => {
                 $m!($crate::types::Time32SecondType $(, $args)*)
             }
-            $crate::repeat_pat!(arrow_schema::DataType::Time32(arrow_schema::TimeUnit::Millisecond), $($data_type),+) => {
+            $crate::repeat_pat!(arrow_schema::DataType::Time32(arrow_schema::TimeUnit::Microsecond), $($data_type),+) => {

Review Comment:
   nice catch!



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