Skip to main content

reifydb_compression/
lib.rs

1// SPDX-License-Identifier: AGPL-3.0-or-later
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};
10
11pub mod select;
12pub mod strategy;
13
14pub type BoxedColumnCompressor = Box<dyn ColumnCompressor>;
15
16pub trait ColumnCompressor: Send + Sync {
17	fn compress(&self, data: &ColumnData) -> reifydb_type::Result<CompressedColumn>;
18	fn decompress(&self, compressed: &CompressedColumn) -> reifydb_type::Result<ColumnData>;
19}
20
21/// Statistics collected during compression
22#[derive(Clone, Debug)]
23pub struct CompressionStatistics {
24	pub original_size: usize,
25	pub compressed_size: usize,
26	pub compression_time_ms: u64,
27	pub compression_ratio: f64,
28}
29
30pub struct CompressionVersion;
31
32impl HasVersion for CompressionVersion {
33	fn version(&self) -> SystemVersion {
34		SystemVersion {
35			name: env!("CARGO_PKG_NAME")
36				.strip_prefix("reifydb-")
37				.unwrap_or(env!("CARGO_PKG_NAME"))
38				.to_string(),
39			version: env!("CARGO_PKG_VERSION").to_string(),
40			description: "Column compression for storage and network".to_string(),
41			r#type: ComponentType::Module,
42		}
43	}
44}