Skip to main content

CompiledEvaluator

Struct CompiledEvaluator 

Source
pub struct CompiledEvaluator<'a> { /* private fields */ }
Expand description

Compiled expression evaluator using the Expression VM.

§Deprecated

This type is deprecated. Use the new, more efficient alternatives:

The new APIs pre-compile expressions eagerly rather than lazily, avoiding cache invalidation issues and providing better performance.

§Migration Guide

Before (CompiledEvaluator):

let mut eval = CompiledEvaluator::new(&registry);
eval.init_columns(&columns);
for row in rows {
    eval.set_row_array(&row);
    let value = eval.evaluate(&expr)?;
}

After (ExpressionEval):

let mut eval = ExpressionEval::compile(&expr, &columns)?;
for row in rows {
    let value = eval.eval(&row)?;
}

§When to use CompiledEvaluator vs new APIs

Use the new APIs (recommended for most cases):

Use CompiledEvaluator when:

  • Expressions change per-row (e.g., after process_correlated_expression)
  • You need dynamic/lazy expression compilation
  • Complex scenarios with correlated subqueries

Implementations§

Source§

impl<'a> CompiledEvaluator<'a>

Source

pub fn new(function_registry: &'a FunctionRegistry) -> Self

Create a new compiled evaluator with a function registry reference

Source

pub fn with_defaults() -> CompiledEvaluator<'static>

Create an evaluator using the global function registry.

Source

pub fn clear(&mut self)

Clear all state for reuse.

Source

pub fn set_transaction_id(&mut self, txn_id: u64)

Set the current transaction ID

Source

pub fn with_params(self, params: ParamVec) -> Self

Set query parameters (positional) - fluent API

Source

pub fn with_named_params(self, named_params: FxHashMap<String, Value>) -> Self

Set named query parameters - fluent API

Source

pub fn with_context(self, ctx: &ExecutionContext) -> Self

Set parameters from execution context - fluent API

PERF: Both params and named_params share the Arc - zero cloning.

Source

pub fn with_row(self, row: Row, columns: &[String]) -> Self

Bind an owned row and its column names for fluent evaluation.

Source

pub fn init_columns(&mut self, columns: &[String])

Initialize the column index mapping (call once before set_row_array)

Repeated semantic schemas avoid cloning; pointer identity is never used because allocator reuse is not a schema identity.

Source

pub fn init_columns_arc(&mut self, columns: CompactArc<Vec<String>>)

Initialize columns from an Arc (zero-copy when schema already has Arc)

This is the preferred method when the caller already has a CompactArc<Vec<String>>, such as from Schema::column_names_arc(). It avoids all string cloning.

Source

pub fn add_aggregate_aliases(&mut self, aliases: &[(String, usize)])

Add aggregate expression aliases for HAVING clause evaluation

Source

pub fn add_expression_aliases(&mut self, aliases: &[(String, usize)])

Add expression aliases for HAVING clause with GROUP BY expressions

Source

pub fn set_row_array(&mut self, row: &Row)

Set the row using array-based access (optimized - no map rebuilding) Call init_columns() once before using this method.

Source

pub fn set_outer_row( &mut self, outer_row: Option<&FxHashMap<CompactArc<str>, Value>>, )

Set the outer row context for correlated subqueries Accepts CompactArc<str> keys directly to avoid conversion overhead.

Source

pub fn set_outer_row_owned( &mut self, outer_row: FxHashMap<CompactArc<str>, Value>, )

Set the outer row context by taking ownership Accepts CompactArc<str> keys directly to avoid conversion overhead.

Source

pub fn take_outer_row(&mut self) -> FxHashMap<CompactArc<str>, Value>

Take ownership of the outer row back (for reuse) Returns CompactArc<str> keys directly to avoid conversion overhead.

Source

pub fn clear_outer_row(&mut self)

Clear the outer row context

Source

pub fn evaluate(&mut self, expr: &Expression) -> Result<Value>

Evaluate an expression to a Value

Source

pub fn evaluate_bool(&mut self, expr: &Expression) -> Result<bool>

Evaluate an expression as a boolean (for WHERE/HAVING clauses)

Returns false for NULL results (SQL three-valued logic).

Trait Implementations§

Source§

impl Default for CompiledEvaluator<'static>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<'a> !RefUnwindSafe for CompiledEvaluator<'a>

§

impl<'a> !UnwindSafe for CompiledEvaluator<'a>

§

impl<'a> Freeze for CompiledEvaluator<'a>

§

impl<'a> Send for CompiledEvaluator<'a>

§

impl<'a> Sync for CompiledEvaluator<'a>

§

impl<'a> Unpin for CompiledEvaluator<'a>

§

impl<'a> UnsafeUnpin for CompiledEvaluator<'a>

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> CompactArcDrop for T

Source§

unsafe fn drop_and_dealloc(ptr: *mut u8)

Drop the contained data and deallocate the header+data allocation. 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> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V