-
Notifications
You must be signed in to change notification settings - Fork 1.9k
perf: optimize factorial function performance #19575
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’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
| } else if a < FACTORIALS.len() as i64 { | ||
| Ok(FACTORIALS[a as usize]) | ||
| } else { | ||
| Err(ArrowError::ComputeError(format!( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it should prob to be exec_err!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks! applied it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @getChan it makes sense as long as input is i64, for bigger input datatypes it would be needed to expand the lookup table, for example duckdb supports larger factorial and converts it to i128
D select factorial(33);
┌───────────────────────────────────────┐
│ factorial(33) │
│ int128 │
├───────────────────────────────────────┤
│ 8683317618811886495518194401280000000 │
└───────────────────────────────────────┘
|
This is very nice 🚀 |
|
@getChan please resolve conflicts |
# Conflicts: # datafusion/functions/Cargo.toml
Which issue does this PR close?
Rationale for this change
benchmark
What changes are included in this PR?
try_unarykernel function onPrimitiveArray. (However, since this isn’tunaryfunction, it does not get vectorized execution)and add benchmark
Are these changes tested?
Yes.
Are there any user-facing changes?
No.