Skip to main content

chronix_engine/segment/
mod.rs

1//! # chronix-segment
2//!
3//! Columnar segment file format (`.csx`) for the Chronix time-series database.
4//!
5//! Segment files are immutable, columnar data files that store time-series data
6//! after it has been flushed from the memtable. Each segment contains:
7//!
8//! - A **header** with file metadata (version, row count, time range).
9//! - One or more **row groups**, each containing encoded column blocks.
10//! - **Column metadata** enabling selective column reads.
11//! - A **footer** with `CRC32c` integrity checksum.
12
13#![warn(missing_docs)]
14
15pub mod bloom;
16pub mod compression;
17pub mod error;
18#[cfg(feature = "field-encryption")]
19pub mod field_encryption;
20pub mod header;
21pub mod metadata;
22pub mod reader;
23pub mod stats;
24pub mod validity;
25pub mod writer;
26
27/// Convert a byte slice to a fixed-size array without panicking.
28///
29/// Returns `SegmentError::CorruptFile` if the slice length doesn't match.
30macro_rules! to_array {
31    ($slice:expr, $ctx:expr) => {
32        $slice
33            .try_into()
34            .map_err(|_| $crate::segment::error::SegmentError::CorruptFile {
35                detail: format!("invalid byte slice length in {}", $ctx),
36            })
37    };
38}
39pub(crate) use to_array;
40
41pub use error::SegmentError;
42#[cfg(feature = "field-encryption")]
43pub use field_encryption::{
44    FieldEncryptionConfig, FieldEncryptionKey, FieldKeyProvider, StaticKeyProvider,
45};
46pub use header::{SegmentFooter, SegmentHeader};
47pub use metadata::{ColumnBlockMeta, ColumnMeta, SegmentMetadata};
48pub use reader::SegmentReader;
49pub use reader::{FieldPredicate, StatsOp};
50pub use stats::ColumnStats;
51pub use validity::{ValidityBuilder, null_buffer_from_bytes};
52pub use writer::{SegmentMeta, SegmentWriter, SegmentWriterConfig};