reifydb_compression/
lib.rs

1// Copyright (c) reifydb.com 2025
2// This file is licensed under the AGPL-3.0-or-later, see license.md file
3
4#![cfg_attr(not(debug_assertions), deny(warnings))]
5
6use reifydb_core::{
7	interface::version::{ComponentType, HasVersion, SystemVersion},
8	value::column::{ColumnData, CompressedColumn},
9};
10
11mod select;
12mod strategy;
13
14pub use select::select_compressor;
15
16pub type BoxedColumnCompressor = Box<dyn ColumnCompressor>;
17
18pub trait ColumnCompressor: Send + Sync {
19	fn compress(&self, data: &ColumnData) -> reifydb_type::Result<CompressedColumn>;
20	fn decompress(&self, compressed: &CompressedColumn) -> reifydb_type::Result<ColumnData>;
21}
22
23/// Statistics collected during compression
24#[derive(Clone, Debug)]
25pub struct CompressionStatistics {
26	pub original_size: usize,
27	pub compressed_size: usize,
28	pub compression_time_ms: u64,
29	pub compression_ratio: f64,
30}
31
32pub struct CompressionVersion;
33
34impl HasVersion for CompressionVersion {
35	fn version(&self) -> SystemVersion {
36		SystemVersion {
37			name: "compression".to_string(),
38			version: env!("CARGO_PKG_VERSION").to_string(),
39			description: "Column compression for storage and network".to_string(),
40			r#type: ComponentType::Module,
41		}
42	}
43}