-
Notifications
You must be signed in to change notification settings - Fork 4k
ARROW-9022: [C++] Add/Sub/Mul arithmetic kernels with overflow check #7420
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
| static enable_if_integer<T> Call(KernelContext* ctx, T left, T right) { | ||
| T result; | ||
| if (__builtin_add_overflow(left, right, &result)) { | ||
| ctx->SetStatus(Status::Invalid("overflow")); |
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.
Which error should we raise? ExecutionError?
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.
I think this is fine for now
|
Shall we have benchmarks for the new operators? |
wesm
left a comment
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.
+1, this looks ok here
| static enable_if_integer<T> Call(KernelContext* ctx, T left, T right) { | ||
| T result; | ||
| if (__builtin_add_overflow(left, right, &result)) { | ||
| ctx->SetStatus(Status::Invalid("overflow")); |
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.
I think this is fine for now
|
@kszucs, yes, let's have benchmarks for the overflow operators, but can be done in a follow up PR |
| ARROW_EXPORT | ||
| Result<Datum> Add(const Datum& left, const Datum& right, ExecContext* ctx = NULLPTR); | ||
| Result<Datum> Add(const Datum& left, const Datum& right, | ||
| ArithmeticOptions options = ArithmeticOptions(), |
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.
We need to document this.
This breaks CI: https://github.com/apache/arrow/runs/786249626
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.
I fixed it in #7492
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!
Quick draft for checked arithmetics.
TODOs:
*Checkedfunctions)