gitedmond opened a new pull request, #52286:
URL: https://github.com/apache/arrow/pull/52286

   ### Rationale for this change
   
   Fixes #52021.
   
   Exporting a sliced fixed-width array through Ruby's MemoryView interface 
advances the data pointer by the element offset in bytes. For an Int32 array 
containing 0 through 7, `slice(1, 3)` therefore exports `[16777216, 33554432, 
50331648]` instead of `[1, 2, 3]`.
   
   ### What changes are included in this PR?
   
   - Calculate the byte offset from the array offset and item size, then pass 
it explicitly to `GetValuesSafe<uint8_t>`.
   - Retain the safe accessor's handling of missing and non-CPU buffers.
   - Preserve existing Boolean export behavior by using a minimum offset 
multiplier of one.
   - Add regression coverage for ten numeric array types, including offsets 1 
and 4, nested slices, and empty slices.
   
   ### Are these changes tested?
   
   Ran the complete `test-memory-view.rb` file through the native Ruby/Fiddle 
interface using Ruby 3.2.3, Fiddle 1.1.8, and Arrow C++/GLib 25.0.1.
   
   The original MemoryView implementation in the 25.0.1 release is identical to 
the current checkout. The extension was rebuilt with this PR's updated 
`memory-view.cpp`.
   
   - Before the fix: 32 tests, 42 assertions, 8 failures, 0 errors.
   - After the fix: 32 tests, 74 assertions, 0 failures, 0 errors, 0 omissions.
   - Both issue examples now return the expected values: `[1, 2, 3]` and `[4, 
5, 6]`.
   - `git diff --check` passes.
   
   The full repository test suite and a complete build of the 26.0.0-SNAPSHOT 
dependencies were not run.
   
   ### Are there any user-facing changes?
   
   MemoryView exports of sliced numeric arrays return the correct underlying 
values.
   
   **This PR contains a "Critical Fix".** It corrects silently incorrect data 
exported from sliced arrays.
   
   ### Was AI used for this PR?
   
   AI assisted with the investigation, implementation, regression tests, 
validation, and PR description.
   
   **PR code and description written by:**
   
   - [ ] Human
   - [x] AI
   
   **Reviewed before submission by:**
   
   - [ ] Human
   - [x] AI
   - [ ] Not reviewed
   


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