Skip to main content

Module codec

Module codec 

Source
Expand description

Compression and encoding for graph property storage.

Graph properties can take up a lot of space - especially string-heavy data like names and labels. This module provides several encoding strategies to shrink your data without losing information.

Data typeBest codecTypical savings
Sorted integers (IDs, timestamps)DeltaBitPacked5-20x smaller
Small integers (ages, counts)BitPackedInts2-16x smaller
Repeated strings (labels, categories)DictionaryEncoding2-50x smaller
Booleans (flags, markers)BitVector8x smaller

Use CodecSelector to automatically pick the best codec for your data, or choose manually when you know your data characteristics.

§Example

use grafeo_core::codec::{TypeSpecificCompressor, CodecSelector};

// Compress sorted integers
let values: Vec<u64> = (100..200).collect();
let compressed = TypeSpecificCompressor::compress_integers(&values);
println!("Compression ratio: {:.1}x", compressed.compression_ratio());

// Compress booleans
let bools = vec![true, false, true, true, false];
let compressed = TypeSpecificCompressor::compress_booleans(&bools);

Re-exports§

pub use bitpack::BitPackedInts;
pub use bitpack::DeltaBitPacked;
pub use bitvec::BitVector;
pub use delta::DeltaEncoding;
pub use delta::zigzag_decode;
pub use delta::zigzag_encode;
pub use dictionary::DictionaryBuilder;
pub use dictionary::DictionaryEncoding;
pub use runlength::Run;
pub use runlength::RunLengthAnalyzer;
pub use runlength::RunLengthEncoding;
pub use runlength::SignedRunLengthEncoding;
pub use selector::CodecSelector;
pub use selector::CompressedData;
pub use selector::CompressionCodec;
pub use selector::CompressionMetadata;
pub use selector::TypeSpecificCompressor;

Modules§

bitpack
Bit-packing for small integers.
bitvec
Stores booleans as individual bits - 8x smaller than Vec<bool>.
delta
Delta encoding for sorted integer sequences.
dictionary
Dictionary encoding for repeated strings.
runlength
Run-length encoding for highly repetitive data.
selector
Automatic codec selection and compression.