fsst-rust 0.1.1

FSST-Rust is a pure rust implementation of the Fast Static Symbol Table
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
use fsst_rust::{decode_string, encode_string};
use fsst_rust::core::codec::Decoder;

fn main() {
    let str = "tumcwitumvldb";
    let (symbol_table, encoding) = encode_string(str, false);
    println!("built symbol table: {}", symbol_table.to_string()); // [b, t, w, tumc, witumvld]
    assert_eq!(str, decode_string(&symbol_table, &encoding));

    let table_bytes = symbol_table.dump();
    let (_, decoder) = Decoder::from_table_bytes(&table_bytes);
    assert_eq!(str, decoder.decode(&encoding));

    let compress_factor = str.len() as f64 / encoding.len() as f64;
    println!("compression factor: {:.4}", compress_factor);
}