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 GenericByteArray (#2946) #2947

Merged
merged 5 commits into from Oct 28, 2022
Merged

Conversation

tustvold
Copy link
Contributor

Which issue does this PR close?

Closes #2946

Rationale for this change

See ticket

What changes are included in this PR?

Defines a GenericByteArray and migrates some methods across, subsequent PRs can then work on eliminating duplication

Are there any user-facing changes?

No 🎉

@github-actions github-actions bot added the arrow Changes to the arrow crate label Oct 27, 2022
@alamb alamb added the api-change Changes to the arrow API label Oct 27, 2022
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.

I think this change looks lovely 😍 -- though I think we should leave it open for a while in case other contributors (such as @viirya and @HaoYang670 ) would like to comment

arrow-array/src/array/byte_array.rs Outdated Show resolved Hide resolved
@@ -0,0 +1,206 @@
// Licensed to the Apache Software Foundation (ASF) under one
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

value_offsets: RawPtrBox<OffsetSize>,
value_data: RawPtrBox<u8>,
}
pub type GenericStringArray<OffsetSize> = GenericByteArray<GenericStringType<OffsetSize>>;
Copy link
Contributor

Choose a reason for hiding this comment

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

This is a very nice cleanup to remove duplication 🏆

arrow-array/src/types.rs Show resolved Hide resolved
arrow-array/src/types.rs Show resolved Hide resolved
arrow-array/src/types.rs Show resolved Hide resolved
Comment on lines +51 to +54
pub fn value_length(&self, i: usize) -> T::Offset {
let offsets = self.value_offsets();
offsets[i + 1] - offsets[i]
}
Copy link
Member

Choose a reason for hiding this comment

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

i may be out of range?

Copy link
Member

Choose a reason for hiding this comment

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

So this should be unsafe?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Slice indexing is checked by default, so it will panic in such a case. We could add an unchecked variant, but at that point the caller might as well just call value_offsets and do this manually

Copy link
Member

@viirya viirya left a comment

Choose a reason for hiding this comment

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

Nice generalization!

@tustvold
Copy link
Contributor Author

I intend to merge this this evening, i.e. in about 6 hours

Copy link
Contributor

@HaoYang670 HaoYang670 left a comment

Choose a reason for hiding this comment

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

Looks good to me. I love this clean-up 👍

@tustvold tustvold removed the api-change Changes to the arrow API label Oct 28, 2022
@tustvold
Copy link
Contributor Author

Removed api-change label as this is not a breaking change

@tustvold tustvold merged commit b6f08a8 into apache:master Oct 28, 2022
@ursabot
Copy link

ursabot commented Oct 28, 2022

Benchmark runs are scheduled for baseline = 73416f8 and contender = b6f08a8. b6f08a8 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

@alamb alamb added api-change Changes to the arrow API and removed api-change Changes to the arrow API labels Oct 28, 2022
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.

Write Generic Code over [Large]BinaryArray and [Large]StringArray
5 participants