Skip to content

Conversation

@tustvold
Copy link
Contributor

@tustvold tustvold commented Oct 6, 2022

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

/// 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];
Copy link
Contributor Author

@tustvold tustvold Oct 6, 2022

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

@github-actions github-actions bot added the arrow Changes to the arrow crate label Oct 7, 2022
@jhorstmann
Copy link
Contributor

This looks like a nice trick 👍

Copy link
Contributor

@alamb alamb left a 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

https://github.com/apache/arrow-rs/blob/master/arrow-array/src/array/struct_array.rs#L103-L111

.unwrap(),
);
assert_eq!(string.value_offsets(), &[0]);
let string = LargeBinaryArray::from(
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
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

@tustvold tustvold merged commit f4ee8b9 into apache:master Oct 13, 2022
@ursabot
Copy link

ursabot commented Oct 13, 2022

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.
Conbench compare runs links:
[Skipped ⚠️ Benchmarking of arrow-rs-commits is not supported on ec2-t3-xlarge-us-east-2] ec2-t3-xlarge-us-east-2
[Skipped ⚠️ Benchmarking of arrow-rs-commits is not supported on test-mac-arm] test-mac-arm
[Skipped ⚠️ Benchmarking of arrow-rs-commits is not supported on ursa-i9-9960x] ursa-i9-9960x
[Skipped ⚠️ Benchmarking of arrow-rs-commits is not supported on ursa-thinkcentre-m75q] ursa-thinkcentre-m75q
Buildkite builds:
Supported benchmarks:
ec2-t3-xlarge-us-east-2: Supported benchmark langs: Python, R. Runs only benchmarks with cloud = True
test-mac-arm: Supported benchmark langs: C++, Python, R
ursa-i9-9960x: Supported benchmark langs: Python, R, JavaScript
ursa-thinkcentre-m75q: Supported benchmark langs: C++, Java

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

Labels

arrow Changes to the arrow crate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Invalid Value Offsets Slice For Empty Variable Length Arrays

4 participants