Yicong-Huang opened a new pull request, #989:
URL: https://github.com/apache/arrow-java/pull/989

   ## What's Changed
   
   Fix `BaseVariableWidthVector`/`BaseLargeVariableWidthVector` IPC 
serialization when `valueCount` is 0.
   
   ### Problem
   
   When `valueCount == 0`, `setReaderAndWriterIndex()` was setting 
`offsetBuffer.writerIndex(0)`, which means `readableBytes() == 0`. IPC 
serializer uses `readableBytes()` to determine buffer size, so 0 bytes were 
written to the IPC stream. This crashes IPC readers in other libraries because 
Arrow spec requires offset buffer to have at least one entry `[0]`.
   
   This is a follow-up to #967 which fixed the same issue in 
`ListVector`/`LargeListVector`.
   
   ### Fix
   
   Simplify `setReaderAndWriterIndex()` to always use `(valueCount + 1) * 
OFFSET_WIDTH` for offset buffer's `writerIndex`. When `valueCount == 0`, this 
correctly sets `writerIndex` to `OFFSET_WIDTH`, ensuring `offset[0]` is 
included in serialization.
   
   ### Testing
   
   Added tests for empty `VarCharVector` and `LargeVarCharVector` verifying 
offset buffer has correct `readableBytes()`.


-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to