Skip to main content

Expr

Enum Expr 

Source
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

Source

pub fn time(self) -> Expr

Source

pub fn value(self) -> Expr

Source

pub fn debug(self) -> Expr

Source

pub fn rolling(self, window_size: usize) -> Expr

Source

pub fn first(self) -> Expr

Source

pub fn last(self) -> Expr

Source

pub fn sum(self) -> Expr

Source

pub fn mean(self) -> Expr

Source

pub fn stddev(self) -> Expr

Source

pub fn min(self) -> Expr

Source

pub fn max(self) -> Expr

Source

pub fn var(self) -> Expr

Source

pub fn skew(self) -> Expr

Source

pub fn count(self) -> Expr

Source

pub fn slope(self) -> Expr

Source

pub fn unique(self) -> Expr

Source

pub fn pow(self, exp: impl Into<Expr>) -> Expr

Source

pub fn lt(self, rhs: impl Into<Expr>) -> Expr

Source

pub fn lte(self, rhs: impl Into<Expr>) -> Expr

Source

pub fn gt(self, rhs: impl Into<Expr>) -> Expr

Source

pub fn gte(self, rhs: impl Into<Expr>) -> Expr

Source

pub fn eq(self, rhs: impl Into<Expr>) -> Expr

Source

pub fn ne(self, rhs: impl Into<Expr>) -> Expr

Source

pub fn between(self, low: impl Into<Expr>, high: impl Into<Expr>) -> Expr

Source

pub fn and(self, rhs: impl Into<Expr>) -> Expr

Source

pub fn or(self, rhs: impl Into<Expr>) -> Expr

Source

pub fn not(self) -> Expr

Source

pub fn neg(self) -> Expr

Source

pub fn abs(self) -> Expr

Source

pub fn add(self, rhs: impl Into<Expr>) -> Expr

Source

pub fn sub(self, rhs: impl Into<Expr>) -> Expr

Source

pub fn mul(self, rhs: impl Into<Expr>) -> Expr

Source

pub fn div(self, rhs: impl Into<Expr>) -> Expr

Source

pub fn clamp(self, min: impl Into<Expr>, max: impl Into<Expr>) -> Expr

Source

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.

Source

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).

Source

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).

Source

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.

Source

pub fn stagnation(self, epsilon: f32) -> Expr

Source

pub fn cast(self, to: DataType) -> Expr

Source

pub fn error(self, target: f32) -> Expr

Relative error from a target: (self - target) / target. Fuses into a single Affine node. target == 0 produces a degenerate expression (division by zero shows up as a NaN/Inf at eval time, then propagates to the outer Clamp).

Source§

impl Expr

Source

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 / Div with one literal operand fuses into a Unary(Affine) (x * 5 + 3Affine { scale: 5, bias: 3 })
  • Nested affines collapse: s2 * (s1*x + b1) + b2Affine(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

Source

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.

Source

pub fn lit(value: impl Into<AnyValue<'static>>) -> Expr

Source

pub fn select(name: impl Into<SmallStr>) -> Expr

Source

pub fn when(cond: impl Into<Expr>) -> When

Source

pub fn every(interval: usize) -> When

Source

pub fn identity() -> Expr

Trait Implementations§

Source§

impl<T> Add<T> for Expr
where T: Into<Expr>,

Source§

type Output = Expr

The resulting type after applying the + operator.
Source§

fn add(self, rhs: T) -> Expr

Performs the + operation. Read more
Source§

impl Clone for Expr

Source§

fn clone(&self) -> Expr

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Expr

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T> Div<T> for Expr
where T: Into<Expr>,

Source§

type Output = Expr

The resulting type after applying the / operator.
Source§

fn div(self, rhs: T) -> Expr

Performs the / operation. Read more
Source§

impl<T> Evaluate<T> for Expr
where T: ExprSelector,

Source§

fn eval<'a>(&'a mut self, metrics: &T) -> Result<AnyValue<'a>, RadiateError>

Source§

impl From<Expr> for Rate

Source§

fn from(expr: Expr) -> Self

Converts to this type from the input type.
Source§

impl From<String> for Expr

Source§

fn from(value: String) -> Self

Converts to this type from the input type.
Source§

impl From<bool> for Expr

Source§

fn from(value: bool) -> Self

Converts to this type from the input type.
Source§

impl From<char> for Expr

Source§

fn from(value: char) -> Self

Converts to this type from the input type.
Source§

impl From<f32> for Expr

Source§

fn from(value: f32) -> Self

Converts to this type from the input type.
Source§

impl From<f64> for Expr

Source§

fn from(value: f64) -> Self

Converts to this type from the input type.
Source§

impl From<i8> for Expr

Source§

fn from(value: i8) -> Self

Converts to this type from the input type.
Source§

impl From<i16> for Expr

Source§

fn from(value: i16) -> Self

Converts to this type from the input type.
Source§

impl From<i32> for Expr

Source§

fn from(value: i32) -> Self

Converts to this type from the input type.
Source§

impl From<i64> for Expr

Source§

fn from(value: i64) -> Self

Converts to this type from the input type.
Source§

impl From<i128> for Expr

Source§

fn from(value: i128) -> Self

Converts to this type from the input type.
Source§

impl From<u8> for Expr

Source§

fn from(value: u8) -> Self

Converts to this type from the input type.
Source§

impl From<u16> for Expr

Source§

fn from(value: u16) -> Self

Converts to this type from the input type.
Source§

impl From<u32> for Expr

Source§

fn from(value: u32) -> Self

Converts to this type from the input type.
Source§

impl From<u64> for Expr

Source§

fn from(value: u64) -> Self

Converts to this type from the input type.
Source§

impl From<u128> for Expr

Source§

fn from(value: u128) -> Self

Converts to this type from the input type.
Source§

impl<T> Mul<T> for Expr
where T: Into<Expr>,

Source§

type Output = Expr

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: T) -> Expr

Performs the * operation. Read more
Source§

impl Neg for Expr

Source§

type Output = Expr

The resulting type after applying the - operator.
Source§

fn neg(self) -> Expr

Performs the unary - operation. Read more
Source§

impl Not for Expr

Source§

type Output = Expr

The resulting type after applying the ! operator.
Source§

fn not(self) -> Expr

Performs the unary ! operation. Read more
Source§

impl PartialEq for Expr

Source§

fn eq(&self, other: &Expr) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for Expr

Source§

impl<T> Sub<T> for Expr
where T: Into<Expr>,

Source§

type Output = Expr

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: T) -> Expr

Performs the - operation. Read more

Auto Trait Implementations§

§

impl Freeze for Expr

§

impl RefUnwindSafe for Expr

§

impl Send for Expr

§

impl Sync for Expr

§

impl Unpin for Expr

§

impl UnsafeUnpin for Expr

§

impl UnwindSafe for Expr

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.