shashank11yadav opened a new pull request, #1016:
URL: https://github.com/apache/arrow-nanoarrow/pull/1016

   Fixes #1015
   
   ## What changed
   
   - `operator[]` in `ViewArrayAsBytes`, `ViewBinaryViewArrayAsBytes` and 
`ViewArrayAsFixedSizeBytes` (`src/nanoarrow/hpp/view.hpp`) now passes 
`range_.offset + i` to `RandomAccessRange::get()`, the same as 
`ViewArrayAs<T>::operator[]` already does.
   - Three regression tests in `src/nanoarrow/hpp/view_test.cc`, one per view. 
Each sets offset 2 and length 2 and checks `view[0]` and `view[1]` through both 
the `ArrowArray` and `ArrowArrayView` constructors. The BinaryView test uses a 
string longer than the inline size, so it also covers the variadic-buffer path.
   
   ## Why
   
   `view[i]` passed the logical index straight to `RandomAccessRange::get()`, 
which takes a physical index. On a sliced array (offset > 0), `view[0]` 
returned the first element of the underlying buffer instead of the first 
element of the slice. Iteration already respected the offset, so the two 
disagreed. This change does not add bounds checking to `operator[]`.
   
   ## How it was tested
   
   - Commit 20b37eb against upstream/main, Debug build with CMake:
     - `cmake --build build` followed by `ctest -R "^NanoarrowHppTest"`: 15 of 
15 tests pass.
     - `ctest -R` for the three new tests: 3 of 3 pass.
     - The same three tests without the fix: 3 of 3 fail.
     - `git diff --check upstream/main`: pass.
   - clang-format 16.0.6 (`--dry-run --Werror`) and codespell 2.2.5 on the 
changed files: clean. `pre-commit run --all-files` was not run.
   - Not run: the full CI matrix (Meson, release, shared and namespaced builds, 
bundled builds, valgrind, clang-tidy).
   


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