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/08/04 03:16:34 UTC

[GitHub] [arrow-rs] JasonLi-cn opened a new pull request, #2314: fix: IPC truncation failure

JasonLi-cn opened a new pull request, #2314:
URL: https://github.com/apache/arrow-rs/pull/2314

   # 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 https://github.com/apache/arrow-rs/issues/2312#issue-1327990182
   
   # 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.
   -->
   fixed ipc truncation bug
   
   # 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] ursabot commented on pull request #2314: fix: IPC writer should truncate string array with all empty string

Posted by GitBox <gi...@apache.org>.
ursabot commented on PR #2314:
URL: https://github.com/apache/arrow-rs/pull/2314#issuecomment-1204768279

   Benchmark runs are scheduled for baseline = e835853aa064f88c7d007c148cd75be140464c6e and contender = d56d88eee5102c1660addc7cb685fdbce38a8efc. d56d88eee5102c1660addc7cb685fdbce38a8efc 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/670976b6ccfa4bc0b78fe3946f9b2ca6...e4811595be47430988ebbddf31955864/)
   [Skipped :warning: Benchmarking of arrow-rs-commits is not supported on test-mac-arm] [test-mac-arm](https://conbench.ursa.dev/compare/runs/2cddeec22f9d483f805286cef3968a90...f78f40622a8447c1a41df3fd6bd9c70b/)
   [Skipped :warning: Benchmarking of arrow-rs-commits is not supported on ursa-i9-9960x] [ursa-i9-9960x](https://conbench.ursa.dev/compare/runs/a831c964d86b4e38af60539aebe86fea...5b0a7ea34f3b455aafdd2e200e0d4f34/)
   [Skipped :warning: Benchmarking of arrow-rs-commits is not supported on ursa-thinkcentre-m75q] [ursa-thinkcentre-m75q](https://conbench.ursa.dev/compare/runs/67f130cafa8d479fb8ae0a4b4338bfe5...70d5709710df4d559829c1eb025e0c84/)
   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] JasonLi-cn commented on pull request #2314: fix: IPC truncation failure

Posted by GitBox <gi...@apache.org>.
JasonLi-cn commented on PR #2314:
URL: https://github.com/apache/arrow-rs/pull/2314#issuecomment-1204721013

   @viirya please 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] viirya commented on a diff in pull request #2314: fix: IPC writer should truncate string array with all empty string

Posted by GitBox <gi...@apache.org>.
viirya commented on code in PR #2314:
URL: https://github.com/apache/arrow-rs/pull/2314#discussion_r937328818


##########
arrow/src/ipc/writer.rs:
##########
@@ -1005,13 +1015,16 @@ fn write_array_data(
         data_type,
         DataType::Binary | DataType::LargeBinary | DataType::Utf8 | DataType::LargeUtf8
     ) {
-        let total_bytes = get_binary_buffer_len(array_data);
-        let value_buffer = &array_data.buffers()[1];
+        let offset_buffer = &array_data.buffers()[0];
+        let value_offset_byte_width = get_value_offset_byte_width(data_type);
+        let min_length = array_data.len() * value_offset_byte_width;

Review Comment:
   Because it is offsets, shouldn't it be `array_data.len() + 1`?



-- 
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] JasonLi-cn commented on a diff in pull request #2314: fix: IPC truncation failure

Posted by GitBox <gi...@apache.org>.
JasonLi-cn commented on code in PR #2314:
URL: https://github.com/apache/arrow-rs/pull/2314#discussion_r937315980


##########
arrow/src/ipc/writer.rs:
##########
@@ -884,6 +884,16 @@ fn get_buffer_element_width(spec: &BufferSpec) -> usize {
     }
 }
 
+/// Returns byte width for binary value_offset buffer spec.
+#[inline]
+fn get_value_offset_byte_width(data_type: &DataType) -> usize {
+    match data_type {
+        DataType::Binary | DataType::Utf8 => 8,
+        DataType::LargeBinary | DataType::LargeUtf8 => 16,

Review Comment:
   It was my negligence, should:
   ```rust
   DataType::Binary | DataType::Utf8 => 4,
   DataType::LargeBinary | DataType::LargeUtf8 => 8,
   ```
   thanks! @HaoYang670 



-- 
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] JasonLi-cn commented on pull request #2314: fix: IPC writer should truncate string array with all empty string

Posted by GitBox <gi...@apache.org>.
JasonLi-cn commented on PR #2314:
URL: https://github.com/apache/arrow-rs/pull/2314#issuecomment-1204731834

   It’s my pleasure @viirya 


-- 
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] JasonLi-cn commented on pull request #2314: fix: IPC writer should truncate string array with all empty string

Posted by GitBox <gi...@apache.org>.
JasonLi-cn commented on PR #2314:
URL: https://github.com/apache/arrow-rs/pull/2314#issuecomment-1204729046

   > 
   
   "It just doesn't truncate the record batch, right?" @viirya 
   yes


-- 
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 #2314: fix: IPC truncation failure

Posted by GitBox <gi...@apache.org>.
HaoYang670 commented on code in PR #2314:
URL: https://github.com/apache/arrow-rs/pull/2314#discussion_r937312559


##########
arrow/src/ipc/writer.rs:
##########
@@ -884,6 +884,16 @@ fn get_buffer_element_width(spec: &BufferSpec) -> usize {
     }
 }
 
+/// Returns byte width for binary value_offset buffer spec.
+#[inline]
+fn get_value_offset_byte_width(data_type: &DataType) -> usize {
+    match data_type {
+        DataType::Binary | DataType::Utf8 => 8,
+        DataType::LargeBinary | DataType::LargeUtf8 => 16,

Review Comment:
   Why is the byte width 8 or 16?



-- 
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] viirya commented on a diff in pull request #2314: fix: IPC truncation failure

Posted by GitBox <gi...@apache.org>.
viirya commented on code in PR #2314:
URL: https://github.com/apache/arrow-rs/pull/2314#discussion_r937325224


##########
arrow/src/ipc/writer.rs:
##########
@@ -1832,4 +1847,23 @@ mod tests {
         assert!(structs.column(1).is_null(1));
         assert_eq!(record_batch_slice, deserialized_batch);
     }
+
+    #[test]
+    fn truncate_ipc_string_array_with_all_empty_string() {
+        fn create_batch() -> RecordBatch {
+            let schema = Schema::new(vec![Field::new("a", DataType::Utf8, true)]);
+            let a =
+                StringArray::from(vec![Some(""), Some(""), Some(""), Some(""), Some("")]);
+            RecordBatch::try_new(Arc::new(schema), vec![Arc::new(a)]).unwrap()
+        }
+
+        let record_batch = create_batch();
+        let record_batch_slice = record_batch.slice(0, 1);
+        let deserialized_batch = deserialize(serialize(&record_batch_slice));
+
+        // dbg!(serialize(&record_batch).len());
+        // dbg!(serialize(&record_batch_slice).len());

Review Comment:
   ```suggestion
   ```



-- 
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] codecov-commenter commented on pull request #2314: fix: IPC writer should truncate string array with all empty string

Posted by GitBox <gi...@apache.org>.
codecov-commenter commented on PR #2314:
URL: https://github.com/apache/arrow-rs/pull/2314#issuecomment-1204733499

   # [Codecov](https://codecov.io/gh/apache/arrow-rs/pull/2314?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
   > Merging [#2314](https://codecov.io/gh/apache/arrow-rs/pull/2314?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (720bef8) into [master](https://codecov.io/gh/apache/arrow-rs/commit/e835853aa064f88c7d007c148cd75be140464c6e?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (e835853) will **increase** coverage by `0.00%`.
   > The diff coverage is `100.00%`.
   
   > :exclamation: Current head 720bef8 differs from pull request most recent head 1ccff32. Consider uploading reports for the commit 1ccff32 to get more accurate results
   
   ```diff
   @@           Coverage Diff           @@
   ##           master    #2314   +/-   ##
   =======================================
     Coverage   81.26%   81.26%           
   =======================================
     Files         248      248           
     Lines       60605    60624   +19     
   =======================================
   + Hits        49249    49268   +19     
     Misses      11356    11356           
   ```
   
   
   | [Impacted Files](https://codecov.io/gh/apache/arrow-rs/pull/2314?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
   |---|---|---|
   | [arrow/src/ipc/writer.rs](https://codecov.io/gh/apache/arrow-rs/pull/2314/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-YXJyb3cvc3JjL2lwYy93cml0ZXIucnM=) | `86.04% <100.00%> (+0.58%)` | :arrow_up: |
   | [...row/src/array/builder/string\_dictionary\_builder.rs](https://codecov.io/gh/apache/arrow-rs/pull/2314/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-YXJyb3cvc3JjL2FycmF5L2J1aWxkZXIvc3RyaW5nX2RpY3Rpb25hcnlfYnVpbGRlci5ycw==) | `90.64% <0.00%> (-0.72%)` | :arrow_down: |
   | [arrow/src/datatypes/datatype.rs](https://codecov.io/gh/apache/arrow-rs/pull/2314/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-YXJyb3cvc3JjL2RhdGF0eXBlcy9kYXRhdHlwZS5ycw==) | `62.30% <0.00%> (-0.32%)` | :arrow_down: |
   | [parquet\_derive/src/parquet\_field.rs](https://codecov.io/gh/apache/arrow-rs/pull/2314/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGFycXVldF9kZXJpdmUvc3JjL3BhcnF1ZXRfZmllbGQucnM=) | `65.75% <0.00%> (-0.23%)` | :arrow_down: |
   | [parquet/src/arrow/schema.rs](https://codecov.io/gh/apache/arrow-rs/pull/2314/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGFycXVldC9zcmMvYXJyb3cvc2NoZW1hLnJz) | `96.93% <0.00%> (+0.17%)` | :arrow_up: |
   
   :mega: Codecov can now indicate which changes are the most critical in Pull Requests. [Learn more](https://about.codecov.io/product/feature/runtime-insights/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   


-- 
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] viirya commented on a diff in pull request #2314: fix: IPC writer should truncate string array with all empty string

Posted by GitBox <gi...@apache.org>.
viirya commented on code in PR #2314:
URL: https://github.com/apache/arrow-rs/pull/2314#discussion_r937328818


##########
arrow/src/ipc/writer.rs:
##########
@@ -1005,13 +1015,16 @@ fn write_array_data(
         data_type,
         DataType::Binary | DataType::LargeBinary | DataType::Utf8 | DataType::LargeUtf8
     ) {
-        let total_bytes = get_binary_buffer_len(array_data);
-        let value_buffer = &array_data.buffers()[1];
+        let offset_buffer = &array_data.buffers()[0];
+        let value_offset_byte_width = get_value_offset_byte_width(data_type);
+        let min_length = array_data.len() * value_offset_byte_width;

Review Comment:
   Shouldn't it be `array_data.len() + 1`?



-- 
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] JasonLi-cn commented on a diff in pull request #2314: fix: IPC writer should truncate string array with all empty string

Posted by GitBox <gi...@apache.org>.
JasonLi-cn commented on code in PR #2314:
URL: https://github.com/apache/arrow-rs/pull/2314#discussion_r937331835


##########
arrow/src/ipc/writer.rs:
##########
@@ -1005,13 +1015,16 @@ fn write_array_data(
         data_type,
         DataType::Binary | DataType::LargeBinary | DataType::Utf8 | DataType::LargeUtf8
     ) {
-        let total_bytes = get_binary_buffer_len(array_data);
-        let value_buffer = &array_data.buffers()[1];
+        let offset_buffer = &array_data.buffers()[0];
+        let value_offset_byte_width = get_value_offset_byte_width(data_type);
+        let min_length = array_data.len() * value_offset_byte_width;

Review Comment:
   yes, I modify it, thanks!



-- 
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] viirya merged pull request #2314: fix: IPC writer should truncate string array with all empty string

Posted by GitBox <gi...@apache.org>.
viirya merged PR #2314:
URL: https://github.com/apache/arrow-rs/pull/2314


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