You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2022/09/08 12:37:29 UTC
[GitHub] [arrow-rs] tustvold opened a new pull request, #2686: Verify valid UTF-8 when converting byte array (#2205)
tustvold opened a new pull request, #2686:
URL: https://github.com/apache/arrow-rs/pull/2686
# Which issue does this PR close?
<!--
We generally require a GitHub issue to be filed for all bug fixes and enhancements and this helps us generate change logs for our releases. You can link an issue to this PR using the GitHub syntax. For example `Closes #123` indicates that this PR will close issue #123.
-->
Closes #2205
# Rationale for this change
<!--
Why are you proposing this change? If this is already explained clearly in the issue then this section is not needed.
Explaining clearly why changes are proposed helps reviewers understand your changes and offer better suggestions for fixes.
-->
# What changes are included in this PR?
<!--
There is no need to duplicate the description in the issue here but it is sometimes worth providing a summary of the individual changes in this PR.
-->
# Are there any user-facing changes?
<!--
If there are user-facing changes then we may require documentation to be updated before approving the PR.
-->
<!---
If there are any breaking changes to public APIs, please add the `breaking change` label.
-->
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow-rs] HaoYang670 commented on a diff in pull request #2686: Verify valid UTF-8 when converting byte array (#2205)
Posted by GitBox <gi...@apache.org>.
HaoYang670 commented on code in PR #2686:
URL: https://github.com/apache/arrow-rs/pull/2686#discussion_r966589860
##########
arrow/src/array/array_string.rs:
##########
@@ -129,8 +129,6 @@ impl<OffsetSize: OffsetSizeTrait> GenericStringArray<OffsetSize> {
}
/// Convert a list array to a string array.
- /// This method is unsound because it does
- /// not check the utf-8 validation for each element.
fn from_list(v: GenericListArray<OffsetSize>) -> Self {
Review Comment:
Validating utf-8 is always slow (it has linear time complexity, I guess).
If users can make sure their values are valid, they can go the unsafe path.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow-rs] HaoYang670 commented on a diff in pull request #2686: Verify valid UTF-8 when converting byte array (#2205)
Posted by GitBox <gi...@apache.org>.
HaoYang670 commented on code in PR #2686:
URL: https://github.com/apache/arrow-rs/pull/2686#discussion_r966589031
##########
arrow/src/array/array_string.rs:
##########
@@ -164,8 +162,7 @@ impl<OffsetSize: OffsetSizeTrait> GenericStringArray<OffsetSize> {
.add_buffer(child_data.buffers()[0].slice(child_data.offset()))
.null_bit_buffer(v.data().null_buffer().cloned());
- let array_data = unsafe { builder.build_unchecked() };
- Self::from(array_data)
+ Self::from(builder.build().unwrap())
Review Comment:
If there is no other expensive validation, then it is good 👍
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow-rs] tustvold commented on a diff in pull request #2686: Verify valid UTF-8 when converting byte array (#2205)
Posted by GitBox <gi...@apache.org>.
tustvold commented on code in PR #2686:
URL: https://github.com/apache/arrow-rs/pull/2686#discussion_r966587181
##########
arrow/src/array/array_string.rs:
##########
@@ -164,8 +162,7 @@ impl<OffsetSize: OffsetSizeTrait> GenericStringArray<OffsetSize> {
.add_buffer(child_data.buffers()[0].slice(child_data.offset()))
.null_bit_buffer(v.data().null_buffer().cloned());
- let array_data = unsafe { builder.build_unchecked() };
- Self::from(array_data)
+ Self::from(builder.build().unwrap())
Review Comment:
There isn't really any other expensive validation that takes place, ultimately the perfomant API is to use the builder
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow-rs] tustvold commented on a diff in pull request #2686: Verify valid UTF-8 when converting byte array (#2205)
Posted by GitBox <gi...@apache.org>.
tustvold commented on code in PR #2686:
URL: https://github.com/apache/arrow-rs/pull/2686#discussion_r966587615
##########
arrow/src/array/array_string.rs:
##########
@@ -129,8 +129,6 @@ impl<OffsetSize: OffsetSizeTrait> GenericStringArray<OffsetSize> {
}
/// Convert a list array to a string array.
- /// This method is unsound because it does
- /// not check the utf-8 validation for each element.
fn from_list(v: GenericListArray<OffsetSize>) -> Self {
Review Comment:
Why is this API needed?
##########
arrow/src/array/array_string.rs:
##########
@@ -129,8 +129,6 @@ impl<OffsetSize: OffsetSizeTrait> GenericStringArray<OffsetSize> {
}
/// Convert a list array to a string array.
- /// This method is unsound because it does
- /// not check the utf-8 validation for each element.
fn from_list(v: GenericListArray<OffsetSize>) -> Self {
Review Comment:
Why is this unsafe API needed?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow-rs] HaoYang670 commented on a diff in pull request #2686: Verify valid UTF-8 when converting byte array (#2205)
Posted by GitBox <gi...@apache.org>.
HaoYang670 commented on code in PR #2686:
URL: https://github.com/apache/arrow-rs/pull/2686#discussion_r966584235
##########
arrow/src/array/array_string.rs:
##########
@@ -164,8 +162,7 @@ impl<OffsetSize: OffsetSizeTrait> GenericStringArray<OffsetSize> {
.add_buffer(child_data.buffers()[0].slice(child_data.offset()))
.null_bit_buffer(v.data().null_buffer().cloned());
- let array_data = unsafe { builder.build_unchecked() };
- Self::from(array_data)
+ Self::from(builder.build().unwrap())
Review Comment:
Do we need to do all the data validation?
We only need to `validate_utf8` I guess.
##########
arrow/src/array/array_string.rs:
##########
@@ -352,8 +349,7 @@ impl<OffsetSize: OffsetSizeTrait> From<GenericBinaryArray<OffsetSize>>
{
fn from(v: GenericBinaryArray<OffsetSize>) -> Self {
Review Comment:
It is better to add some comments here such as "This function is slow because it checks the utf8 validation. Please use `from_list_unchecked` if you can make sure values are valid utf8 strings". (I am not sure whether we could add docs for the From trait)
##########
arrow/src/array/array_string.rs:
##########
@@ -352,8 +349,7 @@ impl<OffsetSize: OffsetSizeTrait> From<GenericBinaryArray<OffsetSize>>
{
fn from(v: GenericBinaryArray<OffsetSize>) -> Self {
let builder = v.into_data().into_builder().data_type(Self::DATA_TYPE);
- let data = unsafe { builder.build_unchecked() };
- Self::from(data)
+ Self::from(builder.build().unwrap())
Review Comment:
We could directly use the `from_list` function.
##########
arrow/src/array/array_string.rs:
##########
@@ -129,8 +129,6 @@ impl<OffsetSize: OffsetSizeTrait> GenericStringArray<OffsetSize> {
}
/// Convert a list array to a string array.
- /// This method is unsound because it does
- /// not check the utf-8 validation for each element.
fn from_list(v: GenericListArray<OffsetSize>) -> Self {
Review Comment:
It is better to preserve the unsafe implementation and rename it `from_list_unchecked`
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow-rs] tustvold commented on a diff in pull request #2686: Verify valid UTF-8 when converting byte array (#2205)
Posted by GitBox <gi...@apache.org>.
tustvold commented on code in PR #2686:
URL: https://github.com/apache/arrow-rs/pull/2686#discussion_r966587388
##########
arrow/src/array/array_string.rs:
##########
@@ -352,8 +349,7 @@ impl<OffsetSize: OffsetSizeTrait> From<GenericBinaryArray<OffsetSize>>
{
fn from(v: GenericBinaryArray<OffsetSize>) -> Self {
let builder = v.into_data().into_builder().data_type(Self::DATA_TYPE);
- let data = unsafe { builder.build_unchecked() };
- Self::from(data)
+ Self::from(builder.build().unwrap())
Review Comment:
This is a binary array not a list?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow-rs] tustvold merged pull request #2686: Verify valid UTF-8 when converting byte array (#2205)
Posted by GitBox <gi...@apache.org>.
tustvold merged PR #2686:
URL: https://github.com/apache/arrow-rs/pull/2686
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow-rs] tustvold commented on a diff in pull request #2686: Verify valid UTF-8 when converting byte array (#2205)
Posted by GitBox <gi...@apache.org>.
tustvold commented on code in PR #2686:
URL: https://github.com/apache/arrow-rs/pull/2686#discussion_r966598781
##########
arrow/src/array/array_string.rs:
##########
@@ -129,8 +129,6 @@ impl<OffsetSize: OffsetSizeTrait> GenericStringArray<OffsetSize> {
}
/// Convert a list array to a string array.
- /// This method is unsound because it does
- /// not check the utf-8 validation for each element.
fn from_list(v: GenericListArray<OffsetSize>) -> Self {
Review Comment:
Which is provided by ArrayData, no?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow-rs] HaoYang670 commented on a diff in pull request #2686: Verify valid UTF-8 when converting byte array (#2205)
Posted by GitBox <gi...@apache.org>.
HaoYang670 commented on code in PR #2686:
URL: https://github.com/apache/arrow-rs/pull/2686#discussion_r966588800
##########
arrow/src/array/array_string.rs:
##########
@@ -352,8 +349,7 @@ impl<OffsetSize: OffsetSizeTrait> From<GenericBinaryArray<OffsetSize>>
{
fn from(v: GenericBinaryArray<OffsetSize>) -> Self {
let builder = v.into_data().into_builder().data_type(Self::DATA_TYPE);
- let data = unsafe { builder.build_unchecked() };
- Self::from(data)
+ Self::from(builder.build().unwrap())
Review Comment:
Op, Sorry my mistake. Also please ignore this comment: https://github.com/apache/arrow-rs/pull/2686#issuecomment-1241452933
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow-rs] ursabot commented on pull request #2686: Verify valid UTF-8 when converting byte array (#2205)
Posted by GitBox <gi...@apache.org>.
ursabot commented on PR #2686:
URL: https://github.com/apache/arrow-rs/pull/2686#issuecomment-1242899013
Benchmark runs are scheduled for baseline = 2d28010ad2691bfdd7429f98848f4be32538bd6f and contender = 8206f013363addad1bf37b2ff96aa44003d70f22. 8206f013363addad1bf37b2ff96aa44003d70f22 is a master commit associated with this PR. Results will be available as each benchmark for each run completes.
Conbench compare runs links:
[Skipped :warning: Benchmarking of arrow-rs-commits is not supported on ec2-t3-xlarge-us-east-2] [ec2-t3-xlarge-us-east-2](https://conbench.ursa.dev/compare/runs/ce3e13f5d72b47dcae5cbf598a2d1db7...9519c26808fa4bba8cd128db49ddc5ef/)
[Skipped :warning: Benchmarking of arrow-rs-commits is not supported on test-mac-arm] [test-mac-arm](https://conbench.ursa.dev/compare/runs/14c0640d04a9495ba4376f1451864be3...fdd79eed618f4ec9952b8e8b8dd19f47/)
[Skipped :warning: Benchmarking of arrow-rs-commits is not supported on ursa-i9-9960x] [ursa-i9-9960x](https://conbench.ursa.dev/compare/runs/2b226bcf871843a9aa92ca0c0b538643...82401277de7e4eefb07ed6781b2ef50f/)
[Skipped :warning: Benchmarking of arrow-rs-commits is not supported on ursa-thinkcentre-m75q] [ursa-thinkcentre-m75q](https://conbench.ursa.dev/compare/runs/d87035b2237d4ac7b4e189c68452be8c...736a105f56d544fa885422e373038062/)
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
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow-rs] tustvold commented on pull request #2686: Verify valid UTF-8 when converting byte array (#2205)
Posted by GitBox <gi...@apache.org>.
tustvold commented on PR #2686:
URL: https://github.com/apache/arrow-rs/pull/2686#issuecomment-1240923075
@HaoYang670 perhaps you might be able to give this one a review?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow-rs] HaoYang670 commented on pull request #2686: Verify valid UTF-8 when converting byte array (#2205)
Posted by GitBox <gi...@apache.org>.
HaoYang670 commented on PR #2686:
URL: https://github.com/apache/arrow-rs/pull/2686#issuecomment-1241452933
This PR should partially, close #2205 I guess, because it doesn't update the `Binary -> String`:
```rust
impl<OffsetSize: OffsetSizeTrait> From<GenericBinaryArray<OffsetSize>>
for GenericStringArray<OffsetSize>
{
fn from(v: GenericBinaryArray<OffsetSize>) -> Self {
let builder = v.into_data().into_builder().data_type(Self::DATA_TYPE);
let data = unsafe { builder.build_unchecked() };
Self::from(data)
}
}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow-rs] tustvold commented on pull request #2686: Verify valid UTF-8 when converting byte array (#2205)
Posted by GitBox <gi...@apache.org>.
tustvold commented on PR #2686:
URL: https://github.com/apache/arrow-rs/pull/2686#issuecomment-1241453759
Oops good spot, will fix that one also
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org