neilconway opened a new pull request, #20623:
URL: https://github.com/apache/datafusion/pull/20623

   ## Which issue does this PR close?
   
   - Closes #20622.
   
   ## Rationale for this change
   
   Several array set operations (e.g., `array_distinct`, `array_union`, 
`array_intersect`, `array_except`) have this property:
   
   * Convert the input(s) using RowConverter, ideally in bulk
   * Apply the set operation as appropriate, which adds or removes elements 
from the set of `Rows`
   * Convert the final set of `Rows` back into `ArrayRef`
   
   However, we can do a little better for the final step: instead of converting 
from `Rows` back into `ArrayRef`, we can just track which indices in the 
input(s) correspond to the values we want to return. We can then grab those 
values with a single `take`, which avoids the Row-to-Arrayref deserialization 
overhead. This is a 5-20% performance win, depending on the set operation and 
the characteristics of the input.
   
   The only wrinkle is that for `intersect` and `union`, because there are 
multiple inputs we need to concatenate the inputs together so that we have a 
single index space. It turns out that this optimization is a win, even 
incurring the `concat` overhead.
   
   ## What changes are included in this PR?
   
   * Add a benchmark for `array_except`
   * Implement this optimization for `array_distinct`, `array_union`, 
`array_intersect`, `array_except`
   
   ## Are these changes tested?
   
   Yes, and benchmarked.
   
   ## Are there any user-facing changes?
   
   No.
   


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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to