elias-fano

Crates.ioelias-fano
lib.rselias-fano
version1.1.0
sourcesrc
created_at2018-07-15 11:50:30.291252
updated_at2019-06-05 11:26:32.13079
descriptionAn implementation of Elias-Fano encoding in Rust
homepage
repositoryhttps://github.com/tomarrell/rust-elias-fano
max_upload_size
id74340
size14,479
Tom Arrell (tomarrell)

documentation

README

Elias-Fano, in Rust

Build Status Rust Docs

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 theorem.

This implementation is based largely on one written in Go by Antonio Mallia, which can be found at his repository amallia/go-ef.

Todo:

  • Tests
  • Example usage
  • Benchmarks, comparison with other implementations

Installation

Add the following line to your Cargo.toml:

[dependencies]
+ elias-fano = "1.1.0"

Example Usage

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()); // 40

    ef.reset();
    println!("{}", ef.value()); // 0

    let _ = ef.visit(3);
    println!("{}", ef.value()); // 1000
}

License

MIT licensed, see LICENSE for more details.

Commit count: 42

cargo fmt