vincev opened a new pull request, #6837:
URL: https://github.com/apache/arrow-datafusion/pull/6837

   # Which issue does this PR close?
   
   Related to discussion in #4973.
   
   # Rationale for this change
   
   This PR improves the median aggregator by reducing the number of 
allocations. 
   
   For this example I am using one year of data from the 
[nyctaxi](https://www.nyc.gov/site/tlc/about/tlc-trip-record-data.page) 
dataset, running  a group by `payment_type` and computing the `total_amount` 
median with the current version it takes ~22secs:
   
   ```
   $ time ./target/release/datafusion-median
   +--------------+--------------+----------+
   | payment_type | total_amount | n        |
   +--------------+--------------+----------+
   | 5            | 5.275        | 6        |
   | 3            | 7.7          | 194323   |
   | 4            | -6.8         | 244364   |
   | 0            | 23.0         | 1368303  |
   | 2            | 13.3         | 7763339  |
   | 1            | 16.56        | 30085763 |
   +--------------+--------------+----------+
   
   real    0m22.861s
   user    1m54.033s
   sys     0m2.872s
   ```
   
   with the changes introduced in this PR we get the same result in 2secs:
   
   ```
   $ time ./target/release/datafusion-median
   +--------------+--------------+----------+
   | payment_type | total_amount | n        |
   +--------------+--------------+----------+
   | 5            | 5.275        | 6        |
   | 3            | 7.7          | 194323   |
   | 4            | -6.8         | 244364   |
   | 0            | 23.0         | 1368303  |
   | 2            | 13.3         | 7763339  |
   | 1            | 16.56        | 30085763 |
   +--------------+--------------+----------+
   
   real    0m2.514s
   user    0m4.725s
   sys     0m1.765s
   ```
   
   
   # What changes are included in this PR?
   
   Reduce number of allocations.
   <!--
   There is no need to duplicate the description in the issue here but it is 
sometimes worth providing a summary of the individual changes in this PR.
   -->
   
   # Are these changes tested?
   
   Run tests locally they all passed.
   <!--
   We typically require tests for all PRs in order to:
   1. Prevent the code from being accidentally broken by subsequent changes
   2. Serve as another way to document the expected behavior of the code
   
   If tests are not included in your PR, please explain why (for example, are 
they covered by existing tests)?
   -->
   
   # Are there any user-facing changes?
   
   <!--
   If there are user-facing changes then we may require documentation to be 
updated before approving the PR.
   -->
   
   <!--
   If there are any breaking changes to public APIs, please add the `api 
change` label.
   -->


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