mod contracts;
mod scalar;
use crate::{db::data::CanonicalSlotReader, error::InternalError, value::Value};
use std::borrow::Cow;
use self::contracts::EffectiveRuntimeFilterProgram;
pub(in crate::db) use contracts::ProjectionEvalError;
#[cfg(any(test, feature = "sql"))]
pub(in crate::db::executor) use scalar::eval_compiled_expr_with_required_slot_reader_cow;
pub(in crate::db::executor) use scalar::eval_compiled_expr_with_value_reader;
pub(in crate::db::executor) use scalar::eval_compiled_expr_with_value_ref_reader;
pub(in crate::db) use scalar::{
eval_compiled_filter_expr_with_required_slot_reader,
eval_compiled_filter_expr_with_value_cow_reader,
};
pub(in crate::db::executor) fn eval_effective_runtime_filter_program_with_slot_reader(
filter_program: &EffectiveRuntimeFilterProgram,
slots: &dyn CanonicalSlotReader,
) -> Result<bool, InternalError> {
if let Some(predicate_program) = filter_program.predicate_program() {
return predicate_program.eval_with_structural_slot_reader(slots);
}
let Some(filter_expr) = filter_program.expression_filter() else {
return Err(InternalError::query_executor_invariant());
};
eval_compiled_filter_expr_with_required_slot_reader(filter_expr, slots)
}
pub(in crate::db::executor) fn eval_effective_runtime_filter_program_with_value_cow_reader<'a, F>(
filter_program: &EffectiveRuntimeFilterProgram,
read_slot: &mut F,
missing_slot_context: &str,
) -> Result<bool, InternalError>
where
F: FnMut(usize) -> Option<Cow<'a, Value>>,
{
if let Some(predicate_program) = filter_program.predicate_program() {
return Ok(predicate_program.eval_with_slot_value_cow_reader(read_slot));
}
let Some(filter_expr) = filter_program.expression_filter() else {
return Err(InternalError::query_executor_invariant());
};
eval_compiled_filter_expr_with_value_cow_reader(filter_expr, read_slot, missing_slot_context)
}