Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/tomarrell/rust-elias-fano
Elias-Fano encoding implementation in Rust
https://github.com/tomarrell/rust-elias-fano
algorithm compression elias-fano encoding hacktoberfest inverted-index rust search-algorithm
Last synced: 13 days ago
JSON representation
Elias-Fano encoding implementation in Rust
- Host: GitHub
- URL: https://github.com/tomarrell/rust-elias-fano
- Owner: tomarrell
- License: mit
- Created: 2018-07-11T12:31:17.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2019-06-05T11:26:27.000Z (over 5 years ago)
- Last Synced: 2024-10-04T12:45:04.301Z (about 1 month ago)
- Topics: algorithm, compression, elias-fano, encoding, hacktoberfest, inverted-index, rust, search-algorithm
- Language: Rust
- Homepage:
- Size: 25.4 KB
- Stars: 29
- Watchers: 4
- Forks: 5
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Elias-Fano, in Rust
[![Build Status](https://img.shields.io/badge/crate-elias--fano-brightgreen.svg)](https://crates.io/crates/elias-fano)
[![Rust Docs](https://img.shields.io/badge/docs.rs-elias--fano-orange.svg)](https://docs.rs/elias-fano)Elias-Fano encoding in Rust.
The Elias-Fano encoding scheme is a quasi-succinct compression method for monotonic integers using gap compression on a Bitset. It allows for decompression of a bit at any position in `O(1)` time complexity.
Being quasi-succinct, it is therefore almost as good as the best theoretical possible compression as determined by the [Shannon-Hartley](https://en.wikipedia.org/wiki/Shannon%E2%80%93Hartley_theorem) theorem.
This implementation is based largely on one written in Go by [Antonio Mallia](https://www.antoniomallia.it/), which can be found at his repository [amallia/go-ef](https://github.com/amallia/go-ef).
## Todo:
- [x] Tests
- [x] Example usage
- [ ] Benchmarks, comparison with other implementations## Installation
Add the following line to your Cargo.toml:
```diff
[dependencies]
+ elias-fano = "1.1.0"
```## Example Usage
```rust
extern crate elias_fano;use elias_fano::EliasFano;
fn main() {
let sorted_array = [0, 3, 40, 1000];
let size = sorted_array.len();let mut ef = EliasFano::new(sorted_array[size - 1], size as u64);
ef.compress(sorted_array.iter());
println!("{}", ef.value()); // 1
match ef.next() {
Ok(val) => println!("Retrieved value: {}", val), // 3
Err(error) => println!("Err: {}", error), // Out of bounds
}let _ = ef.next();
println!("{}", ef.value()); // 40ef.reset();
println!("{}", ef.value()); // 0let _ = ef.visit(3);
println!("{}", ef.value()); // 1000
}
```## License
MIT licensed, see LICENSE for more details.