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:
ExpressionEval- For single expression evaluation (most common case)RowFilter- For closure-based filtering (Send+Sync safe)JoinFilter- For join condition evaluationMultiExpressionEval- For SELECT projections (multiple expressions)
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(®istry);
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):
ExpressionEval- Single expression with static schemaRowFilter- WHERE clause filtering (thread-safe)MultiExpressionEval- SELECT projections (multiple expressions)
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>
impl<'a> CompiledEvaluator<'a>
Sourcepub fn new(function_registry: &'a FunctionRegistry) -> Self
pub fn new(function_registry: &'a FunctionRegistry) -> Self
Create a new compiled evaluator with a function registry reference
Sourcepub fn with_defaults() -> CompiledEvaluator<'static>
pub fn with_defaults() -> CompiledEvaluator<'static>
Create an evaluator using the global function registry.
Sourcepub fn set_transaction_id(&mut self, txn_id: u64)
pub fn set_transaction_id(&mut self, txn_id: u64)
Set the current transaction ID
Sourcepub fn with_params(self, params: ParamVec) -> Self
pub fn with_params(self, params: ParamVec) -> Self
Set query parameters (positional) - fluent API
Sourcepub fn with_named_params(self, named_params: FxHashMap<String, Value>) -> Self
pub fn with_named_params(self, named_params: FxHashMap<String, Value>) -> Self
Set named query parameters - fluent API
Sourcepub fn with_context(self, ctx: &ExecutionContext) -> Self
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.
Sourcepub fn with_row(self, row: Row, columns: &[String]) -> Self
pub fn with_row(self, row: Row, columns: &[String]) -> Self
Bind an owned row and its column names for fluent evaluation.
Sourcepub fn init_columns(&mut self, columns: &[String])
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.
Sourcepub fn init_columns_arc(&mut self, columns: CompactArc<Vec<String>>)
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.
Sourcepub fn add_aggregate_aliases(&mut self, aliases: &[(String, usize)])
pub fn add_aggregate_aliases(&mut self, aliases: &[(String, usize)])
Add aggregate expression aliases for HAVING clause evaluation
Sourcepub fn add_expression_aliases(&mut self, aliases: &[(String, usize)])
pub fn add_expression_aliases(&mut self, aliases: &[(String, usize)])
Add expression aliases for HAVING clause with GROUP BY expressions
Sourcepub fn set_row_array(&mut self, row: &Row)
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.
Sourcepub fn set_outer_row(
&mut self,
outer_row: Option<&FxHashMap<CompactArc<str>, Value>>,
)
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.
Sourcepub fn set_outer_row_owned(
&mut self,
outer_row: FxHashMap<CompactArc<str>, Value>,
)
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.
Sourcepub fn take_outer_row(&mut self) -> FxHashMap<CompactArc<str>, Value>
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.
Sourcepub fn clear_outer_row(&mut self)
pub fn clear_outer_row(&mut self)
Clear the outer row context
Sourcepub fn evaluate(&mut self, expr: &Expression) -> Result<Value>
pub fn evaluate(&mut self, expr: &Expression) -> Result<Value>
Evaluate an expression to a Value
Sourcepub fn evaluate_bool(&mut self, expr: &Expression) -> Result<bool>
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).