Skip to main content

reifydb_compression/
lib.rs

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