Compress impls

This commit is contained in:
Hugh Kaznowski
2026-09-07 02:04:36 +01:00
parent 55820982b1
commit f96de8f38d
3 changed files with 22 additions and 92 deletions
+14 -24
View File
@@ -54,6 +54,7 @@ pub(crate) struct EngineSnapshot {
pub(crate) ingest_lag_high_watermark_ms: i64,
}
// --- core: snapshot construction and log range access ---
impl EngineSnapshot {
pub(crate) fn metric_declarations_range(
&self,
@@ -218,16 +219,7 @@ impl EngineSnapshot {
}
}
impl EngineSnapshot {
pub(crate) fn handle_query_ro(&self, query: EngineQuery) -> EngineResponse {
handle_query_inner(self, query, SortHelperAccess::Immutable(&self.sort_helper_indexes))
}
pub(crate) fn has_sort_helper_index(&self, sort_by: &str) -> bool {
self.sort_helper_indexes.contains_key(sort_by)
}
}
// --- filter: compiling search-bar filter expressions ---
impl EngineSnapshot {
pub(in crate::engine::snapshot) fn compile_filter_query(&self, filter: &str, now: Timestamp) -> Result<CompiledFilter, String> {
let expr = filter_parser::parse(filter).map_err(|err| err.to_string())?;
@@ -308,6 +300,7 @@ impl EngineSnapshot {
}
}
// --- metrics: declaring, applying, and querying metric buckets ---
impl EngineSnapshot {
pub(crate) fn validate_metric_request(&self, request: &DeclareMetricRequest) -> Result<Regex, String> {
let re = Regex::new(&request.message_match_regex)
@@ -424,9 +417,7 @@ impl EngineSnapshot {
self.clear_metric_data(name);
existed
}
}
impl EngineSnapshot {
#[allow(clippy::too_many_arguments)]
fn apply_metric_to_log(
&mut self,
@@ -597,9 +588,7 @@ impl EngineSnapshot {
})
.flatten()
}
}
impl EngineSnapshot {
pub(crate) fn declared_value_kind(&self, metric_name: &str) -> Option<MetricPrimitiveKind> {
match self.index.get(&IndexKey::MetricDeclaration { name: metric_name.to_string() }) {
Some(DataValue::MetricDeclaration { value_param, .. }) => Some(
@@ -619,6 +608,7 @@ impl EngineSnapshot {
}
}
// --- params: declaring and resolving param values ---
impl EngineSnapshot {
pub(crate) fn validate_param_declaration(&self, request: &DeclareParamRequest) -> Result<(), String> {
if OTTYL_RESERVED_PARAM_NAMES.contains(&request.name.as_str()) {
@@ -666,9 +656,7 @@ impl EngineSnapshot {
DataValue::ParamDeclaration(ParamDeclaration { auto_derived: false, ..request }),
);
}
}
impl EngineSnapshot {
fn auto_derived_param_count(&self) -> usize {
self.param_declarations_range().filter(|declaration| declaration.6).count()
}
@@ -734,9 +722,7 @@ impl EngineSnapshot {
total += 1;
}
}
}
impl EngineSnapshot {
pub(crate) fn derive_log_stream_params_from_row(
&mut self,
header: &crate::engine::logfmt::LogStreamHeader,
@@ -795,9 +781,7 @@ impl EngineSnapshot {
}
}
}
}
impl EngineSnapshot {
pub(crate) fn clear_all_param_declarations(&mut self) -> usize {
let names: Vec<String> =
self.param_declarations_range().map(|(name, ..)| name.to_string()).collect();
@@ -818,9 +802,7 @@ impl EngineSnapshot {
let reextracted = self.param_declarations_range().count();
(reextracted, logs_considered)
}
}
impl EngineSnapshot {
pub(in crate::engine::snapshot) fn resolved_param_declarations(&self) -> HashMap<String, ResolvedParam> {
self.param_declarations_range()
.filter_map(|(name, _, capture_group, json_field_path, kind, elapsed_since_last, _, log_stream_gated)| {
@@ -840,9 +822,7 @@ impl EngineSnapshot {
})
.collect()
}
}
impl EngineSnapshot {
pub(in crate::engine::snapshot) fn resolve_param_value(
&mut self,
metric_name: &str,
@@ -876,7 +856,16 @@ impl EngineSnapshot {
}
}
// --- query: EngineQuery/PromQL evaluation ---
impl EngineSnapshot {
pub(crate) fn handle_query_ro(&self, query: EngineQuery) -> EngineResponse {
handle_query_inner(self, query, SortHelperAccess::Immutable(&self.sort_helper_indexes))
}
pub(crate) fn has_sort_helper_index(&self, sort_by: &str) -> bool {
self.sort_helper_indexes.contains_key(sort_by)
}
pub(crate) fn evaluate_promql(
&self,
parsed: &PromqlQuery,
@@ -1050,6 +1039,7 @@ impl EngineSnapshot {
}
}
// --- sort: sort-helper index maintenance ---
impl EngineSnapshot {
pub(super) fn build_sort_helper_index(&self, sort_by: &str) -> BTreeMap<SortHelperKey, Timestamp> {
let compiled_params = self.compiled_param_declarations();