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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ArrowArrayViewGetIntervalUnsafe #270

Merged
merged 3 commits into from
Aug 1, 2023
Merged

Conversation

WillAyd
Copy link
Contributor

@WillAyd WillAyd commented Jul 28, 2023

Follow on to #258

@codecov-commenter
Copy link

Codecov Report

Merging #270 (a46400f) into main (31ed814) will decrease coverage by 0.01%.
The diff coverage is 68.18%.

@@            Coverage Diff             @@
##             main     #270      +/-   ##
==========================================
- Coverage   87.14%   87.14%   -0.01%     
==========================================
  Files          63       66       +3     
  Lines        9750    10129     +379     
==========================================
+ Hits         8497     8827     +330     
- Misses       1253     1302      +49     
Files Changed Coverage Δ
src/nanoarrow/array_inline.h 88.53% <68.18%> (-0.79%) ⬇️

... and 3 files with indirect coverage changes

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

Copy link
Member

@paleolimbot paleolimbot left a comment

Choose a reason for hiding this comment

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

Thank you! (And thank you for fixing the CI error). Just a few notes!

src/nanoarrow/array_inline.h Outdated Show resolved Hide resolved
break;
}
default:
out = NULL;
Copy link
Member

Choose a reason for hiding this comment

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

maybe memset(out, 0, sizeof(struct ArrowInterval)?

Copy link
Member

Choose a reason for hiding this comment

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

Or setting all components to 0? Or nothing? It's undefined behaviour but I'm not sure what out = NULL would actually do.

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 think the downside to setting to 0 is that it is ambiguous if you've had an error or an interval is legitimately 0

Copy link
Member

Choose a reason for hiding this comment

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

Agreed... perhaps nothing then so that nobody relies on that behavior?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure removed that for now. Another thought I had was returning an ArrowInterval; that would break the usage pattern with GetDecimalUnsafe but arguably be more consistent with GetStringUnsafe, GetBytesUnsafe, etc...

Those methods do assign some members to NULL so the caller has a way of checking if they've made a mistake

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 the motivation there was to make it more likely that some test would fail...perhaps some future documentation could make it more clear that it's the caller's responsibility to type check first (in theory that's what the Unsafe bit is trying to communicate).

Returning the ArrowInterval is definitely an option...my hunch is that it would be inefficient since it you'd have to potentially copy a few of the fields for every item in the loop; however, I have no evidence for that. I think what you have here is a good compromise to support all three interval types. If there's overwhelming feedback suggesting that it's confusing or slow it can always be changed pre 1.0.

src/nanoarrow/array_test.cc Outdated Show resolved Hide resolved
Copy link
Member

@paleolimbot paleolimbot left a comment

Choose a reason for hiding this comment

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

Thank you!

@paleolimbot paleolimbot merged commit 5c3e149 into apache:main Aug 1, 2023
27 checks passed
@WillAyd WillAyd deleted the get-interval branch September 5, 2024 15:28
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