[C++][Compute] Implement casting from ListView/LargeListView to List/LargeList
- Dominant language
- C++
- Stars
- 17.1k
- Forks
- 4.3k
- Avg merge
- 3d 13h
- Merged PRs (30d)
- 88
Description
### Describe the enhancement requested
Currently, Apache Arrow C++ does not support casting from ListView or LargeListView arrays to standard List or LargeList arrays correctly.
Although the casting kernels are registered, they incorrectly route to the standard List-to-List casting kernel (`CastList`). Because `CastList` ignores the sizes buffer of `ListView` (assuming contiguous elements where size is `offset[i+1] - offset[i]`) and attempts to read `length + 1` offsets from a buffer that may only contain `length` elements, casting a `ListView` to `List` silently produces a corrupted `ListArray` with invalid/negative offsets and triggers out-of-bounds reads.
This enhancement introduces a dedicated casting path for ListView/LargeListView:
1) A fast-path for contiguous ListView inputs, performing zero-copy casting by slicing the child values array and adjusting offsets.
2) A fallback path for non-contiguous, gapped, or overlapping ListView inputs, using indices generation and the `take` kernel to reconstruct contiguous child values arrays before casting.
### Component(s)
C++
Contributor guide
Assessment
This issue has not been assessed yet.