LSPH - Learned SPatial HashMap

fast 2d point query powered by hashmap and statistic model

Github Workflow crates.io version dos.io

The original paper of LSPH can be found [here].

The LSPH uses a learned model such as a linear regression model as the hash function to predict the index in a hashmap. As a result, the learned model is more fitted to the data that stored in the hashmap, and reduces the chance of hashing collisions. Moreover, if the learned model is monotonic function(e.g. linear regression), the hash indexes are increasing as the input data increases. This property can be used to create a sorted order of buckets in a hashmap, which allow us to do range searches in a hashmap.

The LSPH supports:

Example:

```rust use lsph::{LearnedHashMap, LinearModel}; let pointdata = vec![[1., 1.], [2., 1.], [3., 2.], [4., 4.]]; let (mut map, points) = LearnedHashMap::, f64>::withdata(&point_data).unwrap();

asserteq!(map.get(&[1., 1.]).issome(), true); asserteq!(map.get(&[3., 1.]).isnone(), true); asserteq!(map.rangesearch(&[0., 0.], &[3., 3.]).issome(), true); asserteq!(map.radiusrange(&[2., 1.], 1.).issome(), true); asserteq!(map.nearestneighbor(&[2., 1.]).is_some(), true); ```

To Run Benchmark:

bash cargo bench

License

Licensed under either of

at your option.