You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "viirya (via GitHub)" <gi...@apache.org> on 2024/05/11 18:35:31 UTC

[I] Compute data buffer length by using start and end values in offset buffer [arrow-rs]

viirya opened a new issue, #5756:
URL: https://github.com/apache/arrow-rs/issues/5756

   **Describe the bug**
   <!--
   A clear and concise description of what the bug is.
   -->
   
   Encountered an issue when importing empty variable-size binary layout array (e.g., string) from Java Arrow.
   
   There is difference between Java Arrow and arrow-rs when computing the length of data buffer: https://github.com/apache/arrow/pull/41610#issuecomment-2103964293
   
   This is how Java Arrow imports an Utf8 array:
   
   ```
   try (ArrowBuf offsets = importOffsets(type, VarCharVector.OFFSET_WIDTH)) {
         final int start = offsets.getInt(0);
         final int end = offsets.getInt(fieldNode.getLength() * (long) VarCharVector.OFFSET_WIDTH);
         final int len = end - start;
         ...
   }
   ```
   
   So even the offset buffer is not initialized, for empty array with one element offset buffer, `end - start` is always 0 that is the length of data buffer. That is why the added roundtrip tests are passed.
   
   But in arrow-rs, it takes the last value of the offset buffer as the length of data buffer, i.e., `end`. If the value is not initialized to zero, the computed length of data buffer is incorrect.
   
   That is what I found for the first offset value from the [spec](https://arrow.apache.org/docs/format/Columnar.html#variable-size-binary-layout):
   
   ```
   Generally the first slot in the offsets array is 0, and the last slot is the length of the values array.
   When serializing this layout, we recommend normalizing the offsets to start at 0.
   ```
   
   It looks like the first value doesn't have to be 0, although generally it is. So seems Java Arrow's approach is (more) correct.
   
   **To Reproduce**
   <!--
   Steps to reproduce the behavior:
   -->
   
   **Expected behavior**
   <!--
   A clear and concise description of what you expected to happen.
   -->
   
   **Additional context**
   <!--
   Add any other context about the problem here.
   -->


-- 
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.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] Compute data buffer length by using start and end values in offset buffer [arrow-rs]

Posted by "tustvold (via GitHub)" <gi...@apache.org>.
tustvold commented on issue #5756:
URL: https://github.com/apache/arrow-rs/issues/5756#issuecomment-2144830603

   `label_issue.py` automatically added labels {'arrow'} from #5741


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


Re: [I] Compute data buffer length by using start and end values in offset buffer [arrow-rs]

Posted by "viirya (via GitHub)" <gi...@apache.org>.
viirya closed issue #5756: Compute data buffer length by using start and end values in offset buffer
URL: https://github.com/apache/arrow-rs/issues/5756


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