Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jackson211/LearnedSPatialHashMap
Learned SPatial Hashmap
https://github.com/jackson211/LearnedSPatialHashMap
data-structures hashmap index spatial
Last synced: 2 months ago
JSON representation
Learned SPatial Hashmap
- Host: GitHub
- URL: https://github.com/jackson211/LearnedSPatialHashMap
- Owner: jackson211
- License: other
- Created: 2021-09-12T09:48:33.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2024-04-17T14:41:00.000Z (9 months ago)
- Last Synced: 2024-11-07T20:03:03.076Z (2 months ago)
- Topics: data-structures, hashmap, index, spatial
- Language: Rust
- Homepage:
- Size: 209 KB
- Stars: 11
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE-APACHE
Awesome Lists containing this project
README
# [LSPH](https://crates.io/crates/lsph) - Learned SPatial HashMap
**fast 2d point query powered by hashmap and statistic model**
![Github Workflow](https://github.com/jackson211/lsph/actions/workflows/rust.yml/badge.svg)
[![crates.io version](https://img.shields.io/crates/v/lsph)](https://crates.io/crates/lsph)
[![dos.io](https://img.shields.io/docsrs/lsph)](https://docs.rs/lsph)
[![dependency status](https://deps.rs/repo/github/jackson211/lsph/status.svg)](https://deps.rs/repo/github/jackson211/lsph)The original paper of LSPH can be found [here].
[here]: https://minerva-access.unimelb.edu.au/items/beb5c0ee-2a8d-5bd2-b349-1190a335ef1a
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:
- Point Query
- Rectange Query
- Radius Range Query
- Nearest Neighbor Query## Example:
```rust
use lsph::{LearnedHashMap, LinearModel};
let point_data = vec![[1., 1.], [2., 1.], [3., 2.], [4., 4.]];
let (mut map, points) = LearnedHashMap::, f64>::with_data(&point_data).unwrap();assert_eq!(map.get(&[1., 1.]).is_some(), true);
assert_eq!(map.get(&[3., 1.]).is_none(), true);
assert_eq!(map.range_search(&[0., 0.], &[3., 3.]).is_some(), true);
assert_eq!(map.radius_range(&[2., 1.], 1.).is_some(), true);
assert_eq!(map.nearest_neighbor(&[2., 1.]).is_some(), true);
```## To Run Benchmark:
```bash
cargo bench
```# License
Licensed under either of
- Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT)at your option.