apache / datafusion

Apache DataFusion SQL Query Engine
https://datafusion.apache.org/
Apache License 2.0
5.48k stars 1.01k forks source link

Use a single HashMap implementation consistently across the code base #677

Open houqp opened 2 years ago

houqp commented 2 years ago

Is your feature request related to a problem or challenge? Please describe what you are trying to do. A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] (This section helps Arrow developers understand the context and why for this feature, in addition to the what)

We are using both std::collections::HashMap and hashbrown::HashMap in datafusion, it would be better to consistently use only one of them.

hashbrown's official readme has the following statement:

Since Rust 1.36, this is now the HashMap implementation for the Rust standard library. However you may still want to use this crate instead since it works in environments without std, such as embedded systems and kernels.

However, it's unclear whether Rust std also uses ahash as the default hasher. If not, it seems like hashbrown would still be a better choice when it comes to performance.

Describe alternatives you've considered A clear and concise description of any alternative solutions or features you've considered.

Additional context

Follow up from https://github.com/apache/arrow-datafusion/pull/676#discussion_r663544711.

Dandandan commented 2 years ago

The hash brown crate is used for those reasons:

I think best would be to define a HashMap type alias, so we can use whatever is set by default across the project.

houqp commented 2 years ago

Agreed, I think we should move all HashMap import to our own pluggable type alias and set hashbrown::HashMap as the default.

alamb commented 2 years ago

hashbrown::HashMap is a good choice 👍 in my opinion