gortsz

Crates.iogortsz
lib.rsgortsz
version0.1.5
created_at2025-06-02 19:37:51.370498+00
updated_at2025-06-03 10:40:13.01508+00
descriptionA rust #![no_std] time series compressor based on the Gorilla whitepaper.
homepagehttps://strathseds.org
repositoryhttps://github.com/X-yl/gortsz
max_upload_size
id1698296
size171,257
Kyle Pereira (X-yl)

documentation

README

gortsz: gorilla time series compression

This is a #![no_std] and no alloc crate implementing Facebook's gorilla compression algorithm for time-series data.

Basic usage:

use gortsz::*;
use gortsz::stats::*;

fn main() {
    let data = [
        (10u32, [1.0, 2.0, 3.3]),
        (11u32, [1.1, 2.2, 2.2]),
        (14u32, [1.2, 2.3, 3.8]),
        (16u32, [1.3, 2.9, 4.9]),
        (18u32, [1.4, 1.0, 3.2]),
    ];

    let buf = [0u8; 256];
    let compressed = match compress::<3, 3, WhitepaperOptions>(
        timeseries.iter(),
        buf.view_bits_mut(),
    ) {
        Ok(compressed) => compressed,
        Err(CompressError {
            valid_bits, ..
        }) => {
            valid_bits // Buffer too small, only partly compressed
        }
    };

    for result in decompressor {
        match result {
            Ok((time, data)) => {
                println!("Decompressed time: {}, data: {:?}", time, data);
                println!("Original time: {}, data: {:?}", reference.0, reference.1);
                assert!(time == reference.0);
                assert!(data == reference.1);
            }
            Err(e) => {
                eprintln!("Decompression error: {}", e);
            }
        }
    }
}

The WhitepaperOptions struct implements the trait CompressionOptions which gives the options described in the whitepaper. Implement this trait to use different options.

Commit count: 9

cargo fmt