Skip to main content

grafeo_core/codec/
mod.rs

1//! Compression and encoding for graph property storage.
2//!
3//! Graph properties can take up a lot of space - especially string-heavy data like
4//! names and labels. This module provides several encoding strategies to shrink
5//! your data without losing information.
6//!
7//! | Data type | Best codec | Typical savings |
8//! | --------- | ---------- | --------------- |
9//! | Sorted integers (IDs, timestamps) | [`DeltaBitPacked`] | 5-20x smaller |
10//! | Small integers (ages, counts) | [`BitPackedInts`] | 2-16x smaller |
11//! | Repeated strings (labels, categories) | [`DictionaryEncoding`] | 2-50x smaller |
12//! | Booleans (flags, markers) | [`BitVector`] | 8x smaller |
13//!
14//! Use [`CodecSelector`] to automatically pick the best codec for your data,
15//! or choose manually when you know your data characteristics.
16//!
17//! # Example
18//!
19//! ```no_run
20//! use grafeo_core::codec::{TypeSpecificCompressor, CodecSelector};
21//!
22//! // Compress sorted integers
23//! let values: Vec<u64> = (100..200).collect();
24//! let compressed = TypeSpecificCompressor::compress_integers(&values).unwrap();
25//! println!("Compression ratio: {:.1}x", compressed.compression_ratio());
26//!
27//! // Compress booleans
28//! let bools = vec![true, false, true, true, false];
29//! let compressed = TypeSpecificCompressor::compress_booleans(&bools).unwrap();
30//! ```
31
32pub mod bitpack;
33pub mod bitvec;
34pub mod delta;
35pub mod dictionary;
36#[cfg(feature = "tiered-storage")]
37pub mod epoch_store;
38pub mod runlength;
39pub mod selector;
40#[cfg(feature = "succinct-indexes")]
41pub mod succinct;
42
43// Re-export commonly used types
44pub use bitpack::{BitPackedInts, DeltaBitPacked};
45pub use bitvec::BitVector;
46pub use delta::{DeltaEncoding, zigzag_decode, zigzag_encode};
47pub use dictionary::{DictionaryBuilder, DictionaryEncoding};
48pub use runlength::{Run, RunLengthAnalyzer, RunLengthEncoding, SignedRunLengthEncoding};
49pub use selector::{
50    CodecSelector, CompressedData, CompressionCodec, CompressionMetadata, TypeSpecificCompressor,
51};
52
53// Tiered storage exports (feature-gated)
54#[cfg(feature = "tiered-storage")]
55pub use epoch_store::{
56    CompressedEpochBlock, CompressionType, EpochBlockHeader, EpochStore, EpochStoreStats,
57    IndexEntry, ZoneMap,
58};
59
60// Succinct data structure exports (feature-gated)
61#[cfg(feature = "succinct-indexes")]
62pub use succinct::{EliasFano, SuccinctBitVector, WaveletTree};