Crates.io | newpfd |
lib.rs | newpfd |
version | 0.8.0 |
source | src |
created_at | 2023-07-20 16:04:48.159115 |
updated_at | 2024-06-24 00:40:45.077488 |
description | NewPFD integer compression/decompression |
homepage | https://github.com/redst4r/newpfd-rs |
repository | https://github.com/redst4r/newpfd-rs |
max_upload_size | |
id | 921432 |
size | 80,980 |
Rust library implementing the NewPFD integer compression/decompression algorithm.
It's currently lacking optimization for speed, but it's decently fast. We perform this on geometrically distributed integers (Geo(lambda=0.01)) to force encoding exceptions in the NewPFD-block.
See benchmarks for details.
For more examples, see the rust-docs.
// Encode some data using NewPFD
use newpfd::newpfd_bitvec::{encode, decode};
let data = vec![10_u64,12,10,1,1,2,3];
let blocksize = 32; // needs to be a mutliple of 32
// encode
let (compressed_data, _) = encode(data.iter().cloned(), blocksize);
// compressed_data is a `bitvec::BitVec` (similar to a Vec<bool>)
// decode
let (decompressed_data, bits_processed) = decode(&compressed_data, data.len(), blocksize);
assert_eq!(data, decompressed_data);
assert_eq!(compressed_data.len(), bits_processed); // the entire bitstream was consumed