use crate::diagnostic::{Code, Diagnostic};
const DEFAULT_DECOMPRESSED_BYTES: u64 = u64::MAX;
const DEFAULT_COMPRESSION_RATIO: u64 = 1_000;
const DEFAULT_NESTING_DEPTH: u32 = 64;
#[derive(Clone, Copy, PartialEq, Eq, Debug)]
pub struct Limits {
pub decompressed_bytes: u64,
pub compression_ratio: u64,
pub rows_per_category: u64,
pub nesting_depth: u32,
pub dictionary_entries: u32,
}
impl Default for Limits {
fn default() -> Self {
Self {
decompressed_bytes: DEFAULT_DECOMPRESSED_BYTES,
compression_ratio: DEFAULT_COMPRESSION_RATIO,
rows_per_category: u64::MAX,
nesting_depth: DEFAULT_NESTING_DEPTH,
dictionary_entries: u32::MAX - 1,
}
}
}
impl Limits {
#[must_use]
pub fn exceeded(limit: &'static str, value: impl std::fmt::Display) -> Diagnostic {
Diagnostic::new(Code::E1901)
.with_context("limit", limit)
.with_context("value", value.to_string())
}
}