pub enum WindowState {
EventCount {
timestamps: VecDeque<i64>,
},
ValueCount {
entries: VecDeque<(i64, String)>,
},
Temporal {
rule_hits: HashMap<String, VecDeque<i64>>,
},
NumericAgg {
entries: VecDeque<(i64, f64)>,
},
}Expand description
Per-group mutable state within a time window.
Each variant matches the type of aggregation being performed.
Variants§
EventCount
For event_count: timestamps of matching events.
ValueCount
For value_count: (timestamp, field_value) pairs.
Temporal
For temporal / temporal_ordered: rule_ref -> list of hit timestamps.
NumericAgg
For value_sum, value_avg, value_percentile, value_median:
(timestamp, numeric_value) pairs.
Implementations§
Source§impl WindowState
impl WindowState
Sourcepub fn new_for(corr_type: CorrelationType) -> Self
pub fn new_for(corr_type: CorrelationType) -> Self
Create a new empty window state for the given correlation type.
Sourcepub fn latest_timestamp(&self) -> Option<i64>
pub fn latest_timestamp(&self) -> Option<i64>
Returns the most recent timestamp in this window, or None if empty.
Sourcepub fn clear(&mut self)
pub fn clear(&mut self)
Clear all entries from the window state (used by CorrelationAction::Reset).
Sourcepub fn push_event_count(&mut self, ts: i64)
pub fn push_event_count(&mut self, ts: i64)
Record an event_count hit.
Sourcepub fn push_value_count(&mut self, ts: i64, value: String)
pub fn push_value_count(&mut self, ts: i64, value: String)
Record a value_count hit with the field value.
Sourcepub fn push_temporal(&mut self, ts: i64, rule_ref: &str)
pub fn push_temporal(&mut self, ts: i64, rule_ref: &str)
Record a temporal hit for a specific rule reference.
Sourcepub fn push_numeric(&mut self, ts: i64, value: f64)
pub fn push_numeric(&mut self, ts: i64, value: f64)
Record a numeric aggregation value.
Sourcepub fn check_condition(
&self,
condition: &CompiledCondition,
corr_type: CorrelationType,
rule_refs: &[String],
extended_expr: Option<&ConditionExpr>,
) -> Option<f64>
pub fn check_condition( &self, condition: &CompiledCondition, corr_type: CorrelationType, rule_refs: &[String], extended_expr: Option<&ConditionExpr>, ) -> Option<f64>
Evaluate the window state against the correlation condition.
Returns Some(aggregated_value) if the condition is satisfied,
None otherwise.
For temporal correlations with an extended expression, the expression is evaluated against the set of rules that have fired in the window.
Trait Implementations§
Source§impl Clone for WindowState
impl Clone for WindowState
Source§fn clone(&self) -> WindowState
fn clone(&self) -> WindowState
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more