Skip to content

Conversation

@kszucs
Copy link
Member

@kszucs kszucs commented Jun 12, 2020

Quick draft for checked arithmetics.

TODOs:

  • more portable overflow checks
  • consolidate the tests
  • add arithmetics options to let the user choose which variant to run (so remove the *Checked functions)

@github-actions
Copy link

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"));
Copy link
Member Author

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?

Copy link
Member

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
Copy link
Member Author

kszucs commented Jun 15, 2020

Shall we have benchmarks for the new operators?

@kszucs kszucs requested a review from wesm June 15, 2020 17:09
Copy link
Member

@wesm wesm left a 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"));
Copy link
Member

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

@wesm
Copy link
Member

wesm commented Jun 18, 2020

@kszucs, yes, let's have benchmarks for the overflow operators, but can be done in a follow up PR

@wesm wesm closed this in dfb3909 Jun 18, 2020
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(),
Copy link
Member

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

Copy link
Member

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

Copy link
Member

Choose a reason for hiding this comment

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

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants