-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Handle empty offsets buffer (#1824) #2836
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
| /// Returns a slice of `OffsetSize` consisting of a single zero value | ||
| #[inline] | ||
| pub(crate) fn empty_offsets<OffsetSize: OffsetSizeTrait>() -> &'static [OffsetSize] { | ||
| static OFFSET: &[i64] = &[0]; |
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.
This slightly odd construction is necessary to workaround the fact Rust doesn't allow statics that depend on type parameters. It gets const folded away by the compiler
|
This looks like a nice trick 👍 |
alamb
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.
Looks like a nice improvement to me -- thanks @tustvold
I wondered if maybe StructArray needed similar treatment but it didn't look like it with my initial review
| .unwrap(), | ||
| ); | ||
| assert_eq!(string.value_offsets(), &[0]); | ||
| let string = LargeBinaryArray::from( |
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.
| let string = LargeBinaryArray::from( | |
| let string = LargeBinaryArray::from( | |
| assert_eq!(string.len(), 0); |
I suggest you add a test for len() as described in the original bug report.
This comment applies to all the tests added in this PR
|
Benchmark runs are scheduled for baseline = f8254e7 and contender = f4ee8b9. f4ee8b9 is a master commit associated with this PR. Results will be available as each benchmark for each run completes. |
Which issue does this PR close?
Closes #1824
Rationale for this change
What changes are included in this PR?
Are there any user-facing changes?
No