rvcreationworld commented on issue #55775:
URL: https://github.com/apache/arrow/issues/55775#issuecomment-7156740728

   Hi @kou @pitrou,
   
   I looked into the failure in `pc.partition_nth_indices` when evaluated on a 
`ChunkedArray`.
   
   ### Findings
   When executing over an `arrow::Array`, `PartitionNthIndicesKernel` accesses 
a single contiguous data buffer. However, when called on a `ChunkedArray`, the 
kernel fails to resolve global logical indices across chunk boundaries, 
resulting in either per-chunk reset indices or out-of-bounds pointer 
dereferences (`SIGSEGV`).
   
   ### Proposed Solution
   1. Avoid materializing a full contiguous copy of the `ChunkedArray` in 
memory to prevent memory doubling on large datasets.
   2. Adapt `PartitionNthIndicesKernel` to follow the pattern used in 
`SortIndices`: create an indirect index array $[0, N-1]$ and supply a custom 
comparator that translates logical index $i$ to `(chunk_idx, offset_in_chunk)` 
via binary search or chunk offset lookup tables.
   3. Add GoogleTest coverage in `vector_sort_test.cc` with multi-chunk arrays 
of varying/empty chunk sizes, including null placement checks 
(`NullPlacement::AtStart` / `AtEnd`).
   
   Would you prefer the chunk offset lookup approach, or is there an ongoing 
effort to generalize `PartitionNth` under the broader Acero chunked compute 
interface?


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