I have a very large HashMap of physical measurements (300k+ entries of 3-element tuples), which I'd like to keep as a HashMap (I could move it out to a SQLite DB and query it, but I'd rather not, for performance reasons). Including it as a literal makes compile times…long. Is there a better approach? Could I serialise it to disk in a binary format, and load it as a HashMap when the binary executes / the library is loaded? Developing and testing using a subset works fine, but I need the full data for production…
So you're hardcoding a hash map? That seems to be a Perfect Hashing problem, see the https://github.com/sfackler/rust-phf crate.
As for the compile times, offload the hash table into a separate crate and Cargo will only recompile this crate when the hash table data changes.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With