Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Arbitrary Number of Arrays in downcast_primitive_array #2809

Merged
merged 1 commit into from Oct 9, 2022

Conversation

tustvold
Copy link
Contributor

@tustvold tustvold commented Sep 29, 2022

Which issue does this PR close?

Closes #.

Rationale for this change

Uses some macro trickery to allow arbitrary numbers of arrays in downcast_primitive_array. Not only is this potentially useful, it reduces code duplication and yields better consistency. Unfortunately this consistency is back-firing slightly, as support for Float16 SIMD arithmetic is not implemented, and this was just left out of the macro 馃槄

What changes are included in this PR?

Are there any user-facing changes?

Float16Array will be downcast in the binary invocation, this probably counts as an API change

@tustvold tustvold added the api-change Changes to the arrow API label Sep 29, 2022
@@ -50,427 +62,183 @@ macro_rules! downcast_primitive_array {
($values:ident => $e:expr, $($p:pat => $fallback:expr $(,)*)*) => {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I eventually hope to split the core logic of downcast_primitive_array into something which maps DataType => ArrowPrimitiveType but this is the first step towards that

@github-actions github-actions bot added the arrow Changes to the arrow crate label Sep 30, 2022
@tustvold tustvold marked this pull request as ready for review October 3, 2022 15:01
@github-actions github-actions bot removed the arrow Changes to the arrow crate label Oct 3, 2022
@tustvold tustvold requested a review from viirya October 6, 2022 05:29
Comment on lines +23 to +33
/// Repeats the provided pattern based on the number of comma separated identifiers
#[doc(hidden)]
#[macro_export]
macro_rules! repeat_pat {
($e:pat, $v_:ident) => {
$e
};
($e:pat, $v_:ident $(, $tail:ident)+) => {
($e, $crate::repeat_pat!($e $(, $tail)+))
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, this is interesting. Nice. 馃憤

(($($values:ident),+) => $e:block $(($($p:pat),+) => $fallback:expr $(,)*)*) => {
$crate::downcast_primitive_array!($($values),+ => $e $($($p),+ => $fallback)*)
};
($($values:ident),+ => $e:block $($($p:pat),+ => $fallback:expr $(,)*)*) => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The number of $p:pat might be different to $values:ident and that will cause error. But the caller should take care of it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, as this is impersonating a match block, I think that is fine

Comment on lines +65 to +70
(($($values:ident),+) => $e:block $($($p:pat),+ => $fallback:expr $(,)*)*) => {
$crate::downcast_primitive_array!($($values),+ => $e $($($p),+ => $fallback)*)
};
(($($values:ident),+) => $e:block $(($($p:pat),+) => $fallback:expr $(,)*)*) => {
$crate::downcast_primitive_array!($($values),+ => $e $($($p),+ => $fallback)*)
};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the difference between this and below? With additional ( )?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, because typically single arguments are not enclosed in ( ) but multiple are, this allows both patterns

@tustvold tustvold merged commit 2ae2309 into apache:master Oct 9, 2022
@ursabot
Copy link

ursabot commented Oct 9, 2022

Benchmark runs are scheduled for baseline = c8321f4 and contender = 2ae2309. 2ae2309 is a master commit associated with this PR. Results will be available as each benchmark for each run completes.
Conbench compare runs links:
[Skipped 鈿狅笍 Benchmarking of arrow-rs-commits is not supported on ec2-t3-xlarge-us-east-2] ec2-t3-xlarge-us-east-2
[Skipped 鈿狅笍 Benchmarking of arrow-rs-commits is not supported on test-mac-arm] test-mac-arm
[Skipped 鈿狅笍 Benchmarking of arrow-rs-commits is not supported on ursa-i9-9960x] ursa-i9-9960x
[Skipped 鈿狅笍 Benchmarking of arrow-rs-commits is not supported on ursa-thinkcentre-m75q] ursa-thinkcentre-m75q
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

@alamb alamb added the arrow Changes to the arrow crate label Dec 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api-change Changes to the arrow API arrow Changes to the arrow crate
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants