pub enum Expr {
Literal(AnyValue<'static>),
Selector(SelectExpr),
Aggregate(AggExpr),
Schedule(ScheduleExpr),
Binary(BinaryExpr),
Unary(UnaryExpr),
Trinary(TrinaryExpr),
}Variants§
Literal(AnyValue<'static>)
Selector(SelectExpr)
Aggregate(AggExpr)
Schedule(ScheduleExpr)
Binary(BinaryExpr)
Unary(UnaryExpr)
Trinary(TrinaryExpr)
Implementations§
Source§impl Expr
impl Expr
pub fn time(self) -> Expr
pub fn value(self) -> Expr
pub fn debug(self) -> Expr
pub fn rolling(self, window_size: usize) -> Expr
pub fn first(self) -> Expr
pub fn last(self) -> Expr
pub fn sum(self) -> Expr
pub fn mean(self) -> Expr
pub fn stddev(self) -> Expr
pub fn min(self) -> Expr
pub fn max(self) -> Expr
pub fn var(self) -> Expr
pub fn skew(self) -> Expr
pub fn count(self) -> Expr
pub fn slope(self) -> Expr
pub fn unique(self) -> Expr
pub fn pow(self, exp: impl Into<Expr>) -> Expr
pub fn lt(self, rhs: impl Into<Expr>) -> Expr
pub fn lte(self, rhs: impl Into<Expr>) -> Expr
pub fn gt(self, rhs: impl Into<Expr>) -> Expr
pub fn gte(self, rhs: impl Into<Expr>) -> Expr
pub fn eq(self, rhs: impl Into<Expr>) -> Expr
pub fn ne(self, rhs: impl Into<Expr>) -> Expr
pub fn between(self, low: impl Into<Expr>, high: impl Into<Expr>) -> Expr
pub fn and(self, rhs: impl Into<Expr>) -> Expr
pub fn or(self, rhs: impl Into<Expr>) -> Expr
pub fn not(self) -> Expr
pub fn neg(self) -> Expr
pub fn abs(self) -> Expr
pub fn add(self, rhs: impl Into<Expr>) -> Expr
pub fn sub(self, rhs: impl Into<Expr>) -> Expr
pub fn mul(self, rhs: impl Into<Expr>) -> Expr
pub fn div(self, rhs: impl Into<Expr>) -> Expr
pub fn clamp(self, min: impl Into<Expr>, max: impl Into<Expr>) -> Expr
Sourcepub fn or_else(self, rhs: impl Into<Expr>) -> Expr
pub fn or_else(self, rhs: impl Into<Expr>) -> Expr
Returns self if it evaluates to a finite number, otherwise rhs.
Triggers fallback on Null, NaN, and ±Inf. Short-circuits — rhs is only
evaluated when needed, so it’s safe to use as a non-trivial default.
Sourcepub fn min_with(self, rhs: impl Into<Expr>) -> Expr
pub fn min_with(self, rhs: impl Into<Expr>) -> Expr
Elementwise min: min(self, rhs). NaN on one side returns the other.
Use as a ceiling: expr.min_with(2.0).
Sourcepub fn max_with(self, rhs: impl Into<Expr>) -> Expr
pub fn max_with(self, rhs: impl Into<Expr>) -> Expr
Elementwise max: max(self, rhs). NaN on one side returns the other.
Use as a floor: expr.max_with(0.05).
Sourcepub fn quantile(self, q: f32) -> Expr
pub fn quantile(self, q: f32) -> Expr
Quantile at q ∈ [0, 1] via linear interpolation between adjacent ranks.
On an empty buffer returns 0.0. Filters non-finite samples before sorting.
O(n log n) per evaluation — fine for window sizes ≤ ~1000.
pub fn stagnation(self, epsilon: f32) -> Expr
pub fn cast(self, to: DataType) -> Expr
Source§impl Expr
impl Expr
Sourcepub fn compile(self) -> Expr
pub fn compile(self) -> Expr
Walks the tree bottom-up and rewrites algebraically equivalent shapes into the smallest possible form. Specifically:
- Pure-literal subtrees fold (
Lit(2) + Lit(3)→Lit(5)) Add/Sub/Mul/Divwith one literal operand fuses into aUnary(Affine)(x * 5 + 3→Affine { scale: 5, bias: 3 })- Nested affines collapse:
s2 * (s1*x + b1) + b2→Affine(s2*s1, s2*b1 + b2)
Called automatically when wrapping in Rate::Expr or NamedExpr. Safe
to call multiple times — idempotent. Mathematically lossless within
f32 precision (and within the existing arithmetic semantics for Null /
non-finite operands).
Source§impl Expr
impl Expr
Sourcepub fn reset(&mut self)
pub fn reset(&mut self)
Recursively clears state in stateful operators: rolling-window buffers
in Aggregate/Buffer nodes and counters in Schedule::Every. Children
of binary/unary/trinary nodes are also visited. Leaf nodes (literals,
selectors) are unaffected.
Use after an engine restart or whenever the controller should “forget” accumulated history.