Skip to content

Add GenericByteArray (#2946)#2947

Merged
tustvold merged 5 commits into
apache:masterfrom
tustvold:add-generic-byte-array
Oct 28, 2022
Merged

Add GenericByteArray (#2946)#2947
tustvold merged 5 commits into
apache:masterfrom
tustvold:add-generic-byte-array

Conversation

@tustvold

Copy link
Copy Markdown
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

@alamb alamb left a comment

Copy link
Copy Markdown
Contributor

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

Comment thread arrow-array/src/array/byte_array.rs Outdated
@@ -0,0 +1,206 @@
// Licensed to the Apache Software Foundation (ASF) under one

Copy link
Copy Markdown
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
Copy Markdown
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 🏆

Comment thread arrow-array/src/types.rs
Comment thread arrow-array/src/types.rs
Comment thread arrow-array/src/types.rs
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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

@viirya viirya left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nice generalization!

Comment thread arrow-array/src/array/byte_array.rs Outdated
Comment thread arrow-array/src/array/byte_array.rs Outdated
@tustvold

Copy link
Copy Markdown
Contributor Author

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

@HaoYang670 HaoYang670 left a comment

Copy link
Copy Markdown
Contributor

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
Copy Markdown
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

ursabot commented Oct 28, 2022

Copy link
Copy Markdown

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