Reserve view slots for empty variable-width vector values
Fixed Arrow Java variable-width view vectors so zero-length values at a view-buffer boundary allocate the complete 16-byte descriptor required for each logical value.
apache/arrow-java · #1192
Arrow vector boundary fix
Empty and null variable-width values now reserve the required fixed-width view slot instead of risking an IndexOutOfBoundsException at buffer boundaries.
Problem
`BaseVariableWidthViewVector.handleSafe` calculated target view-buffer capacity partly from payload length. For an empty value at the boundary, that calculation could omit the target index's fixed-width view slot and trigger an IndexOutOfBoundsException across empty-write, null, and fill-generated value paths.
Approach
Changed capacity planning to reserve `(index + 1) * ELEMENT_SIZE`, rounded to the 16-byte view width, independently of payload bytes. Added parameterized boundary tests for empty writes, `setValueCount` fills, and null values across both string and binary view vectors.
Impact and scope
- Prevents zero-length and null values from under-allocating the view buffer at allocation boundaries.
- Preserves Arrow's invariant of one 16-byte view descriptor for every logical vector value, regardless of payload length.
- Protects both `ViewVarCharVector` and `ViewVarBinaryVector` across direct writes, filled gaps, and null assignment.
Validation
- Added focused regression coverage for empty values at the first view-buffer boundary.
- Covered `setSafe`, `setValueCount`, and `setNull` behavior under both variable-width view vector implementations.
- All three authored commits and the merge commit are GitHub-verified; the fix received three maintainer approvals and closed GH-1190 as completed.