binary-signal opened a new pull request, #2158: URL: https://github.com/apache/fluss/pull/2158
Linked issue: close #2157 ### Purpose The `to*Array()` methods in `BinaryArray` were passing `*_ARRAY_OFFSET` constants (e.g., `DOUBLE_ARRAY_OFFSET`) as the `targetOffset` parameter to `BinarySegmentUtils.copyToUnsafe()`. These constants are Unsafe memory offsets (typically 16 bytes on 64-bit JVMs), but `copyToUnsafe()` uses `targetOffset` as a regular Java array index. For example, with a 20-element double array: - `targetOffset = DOUBLE_ARRAY_OFFSET ≈ 16` - The code tried to access `target[16 + 0]` through `target[16 + 19 = 35]` - This caused `ArrayIndexOutOfBoundsException: Index 20 out of bounds for length 20` ### Brief change log Changed all `to*Array()` methods to pass `0` as the `targetOffset` since `copyToUnsafe()` uses regular Java array indexing, not Unsafe memory operations. ### Tests - [x] Added 7 new tests (`testTo*ArrayWithLargeArray`) that verify all primitive array conversion methods work correctly with 20-element arrays - [x] All existing `BinaryArrayTest` tests pass - [x] All `BinarySegmentUtilsTest` tests pass Here are all the test methods added to `BinaryArrayTest.java`: testToDoubleArrayWithLargeArray() testToFloatArrayWithLargeArray() testToLongArrayWithLargeArray() testToIntArrayWithLargeArray() testToShortArrayWithLargeArray() testToByteArrayWithLargeArray() testToBooleanArrayWithLargeArray() testToDoubleArrayWithLargeArray -- 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]
