Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support partitioning functionality #4476

Open
Dandandan opened this issue Jul 2, 2023 · 3 comments
Open

Support partitioning functionality #4476

Dandandan opened this issue Jul 2, 2023 · 3 comments
Labels
enhancement Any new improvement worthy of a entry in the changelog performance

Comments

@Dandandan
Copy link
Contributor

Is your feature request related to a problem or challenge? Please describe what you are trying to do.

In DataFusion, a common operation is to repartition a RecordBatch by hashing one or more columns and dividing them into partition record batches using the "formula" hash % num_partitions.

The current approach is to create the indices that match and use them to take the individual arrays (see BatchPartitioner in datafusion).

This is relatively expensive however, as we visit the arrays num_partitions times in different places, leading to cache inefficient.

Describe the solution you'd like

I would like to have a method in arrow-rs that takes an Array with partition numbers (0..) and spreads the rows of the Array(s) into a Vec<Array> and/or Vec<RecordBatch>.

Describe alternatives you've considered

Additional context

@Dandandan Dandandan added enhancement Any new improvement worthy of a entry in the changelog performance labels Jul 2, 2023
@tustvold
Copy link
Contributor

tustvold commented Jul 2, 2023

Makes sense to me, of course assuming it empirically shows a performance improvement over using take. It occurs to me this would trade write locality for read locality, which may not be beneficial.

@Dandandan
Copy link
Contributor Author

Yeah agree, we'll have to benchmark it.

I expect though that write locality won't be as bad as the current read locality...

@richox
Copy link
Contributor

richox commented Jul 6, 2023

it is better to take multiple input arrays than a single array? it makes many small fragment arrays (which has less performance and wastes a lot of memory) if the number of partitions is big.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Any new improvement worthy of a entry in the changelog performance
Projects
None yet
Development

No branches or pull requests

3 participants