pepijnve opened a new issue, #8752: URL: https://github.com/apache/arrow-rs/issues/8752
**Is your feature request related to a problem or challenge? Please describe what you are trying to do.** The `zip` algorithm requires two arrays of equal length. This requires callers to ensure the truth and false values are correctly aligned before calling `zip`. When `zip` is used to merge two partial results, this can be cumbersome. Consider a typical pattern where you want to conditionally compute one value or another for a single input array depending on a predicate: 1. A boolean array is derived by evaluating a predicate on the input array (e.g., values > threshold) 2. The `filter` function is used with this boolean array to extract elements where the predicate is `true`, and with its complement to extract elements where the predicate is `false` 3. Separate computations are performed on these two filtered arrays (e.g., compute_a(true_values) and compute_b(false_values)) .4 The results are two arrays that are smaller than the original array. To use `zip`, these results must first be "scattered" back to their original indices to create two full-length arrays where each position aligns with the original boolean mask This scatter step is can be a bit wasteful because it requires allocating additional memory and copying values to intermediate arrays that exist solely to satisfy `zip`'s equal-length requirement. It would be nice to be able to avoid this intermediate step. **Describe the solution you'd like** Some array combination algorithm that does not require the values in the input arrays to be aligned. **Describe alternatives you've considered** Use `interleave`. The `interleave` algorithm can be used to achieve the desired result, but this requires computing an index array that's more complex than necessary. In the example given above, the boolean array has already been computed. It would be nice to be able to use that as is for the merge operation. **Additional context** None -- 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]
