alamb opened a new issue, #11255:
URL: https://github.com/apache/arrow-rs/issues/11255

   **Is your feature request related to a problem or challenge? Please describe 
what you are trying to do.**
   
   - Follow on to  #10859
   
   #10859  adds a small special case in 
[`narrow_batch`](https://github.com/apache/arrow-rs/blob/919f8475f0fbdd727a9aae44402ce44a878901d1/parquet/src/arrow/arrow_reader/filter.rs#L366-L380)
 in the parquet reader: when the
   boolean filter selects exactly one contiguous run of rows, the batch is 
narrowed with a
   zero-copy `RecordBatch::slice` instead of `filter_record_batch`.
   
   ```rust
   fn narrow_batch(batch: &RecordBatch, filter: &BooleanArray, true_count: 
usize) -> Result<RecordBatch, ArrowError> {
       let mut slices = SlicesIterator::new(filter);
       let (start, end) = slices.next().expect("a partially selected filter has 
a true slice");
       if end - start == true_count {
           Ok(batch.slice(start, end - start))
       } else {
           filter_record_batch(batch, filter)
       }
   }
   ```
   
   This optimization only helps that one call site, but could also be applied 
to the `filter` kernel in `arrow_select`
   
   
   It already returns a zero-copy slice when the predicate selects every row
   (`IterationStrategy::All` in `filter_array`),
   
   
   **Describe the solution you'd like**
   
   Teach the `arrow_select` filter kernel to recognize a single contiguous run 
and return
   `values.slice(start, len)` for it, the same way it already handles `All`, 
and combine `narrow_batch` in the parquet reader to
   call `filter_record_batch`.
   
   
   **Describe alternatives you've considered**
   
   - Leave the special case in `narrow_batch`. This works but benefits only the 
parquet
     fused-predicate path and duplicates logic the kernel should own.
   - Have callers check for a single run themselves before calling `filter`. 
This pushes the
     same duplication to every call site.
   
   **Additional context**
   
   - Introduced in #10859
   - The `All` fast path lives in `filter_array` in `arrow-select/src/filter.rs`
   - Strategy selection is in `IterationStrategy::default_strategy` and
     `FilterBuilder::optimize` in the same file
   


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