pub struct Compiler { /* private fields */ }Expand description
Implementations§
Source§impl Compiler
impl Compiler
Sourcepub fn set_max_active_rules(&mut self, max: usize)
pub fn set_max_active_rules(&mut self, max: usize)
Set the maximum active rules for TensorMaskedJoin (16..=128).
Sourcepub fn compile(&mut self, source: &str) -> Result<ExecutionPlan>
pub fn compile(&mut self, source: &str) -> Result<ExecutionPlan>
Compile XLOG source code into an execution plan.
This is the main entry point for compilation. It chains together:
- Parsing (source → AST)
- Stratification (analyze dependencies, check for cycles)
- Lowering (AST → Relational IR execution plan)
§Arguments
source- The XLOG source code as a string
§Returns
Ok(ExecutionPlan)- The compiled execution plan ready for executionErr(XlogError)- If any compilation phase fails:XlogError::Parse- Syntax errors in the sourceXlogError::StratificationCycle- Unstratifiable negation/aggregationXlogError::Compilation- Other semantic errors
§Example
let mut compiler = Compiler::new();
// Compile a simple transitive closure program
let plan = compiler.compile(r#"
edge(1, 2).
edge(2, 3).
reach(X, Y) :- edge(X, Y).
reach(X, Z) :- reach(X, Y), edge(Y, Z).
"#)?;
// The plan can now be executed by xlog-runtimeSourcepub fn compile_with_stats_snapshot(
&mut self,
source: &str,
stats_snapshot: Option<&StatsSnapshot>,
) -> Result<ExecutionPlan>
pub fn compile_with_stats_snapshot( &mut self, source: &str, stats_snapshot: Option<&StatsSnapshot>, ) -> Result<ExecutionPlan>
Compile XLOG source code into an execution plan, optionally seeding the optimizer with a runtime statistics snapshot.
This entry point delegates through the composable config-aware API
with CompilerConfig::default(), which preserves existing triangle,
4-cycle, recursive, and selectivity-aware dispatch behavior
bit-identically.
Sourcepub fn compile_with_config_and_stats_snapshot(
&mut self,
source: &str,
config: &CompilerConfig,
stats_snapshot: Option<&StatsSnapshot>,
) -> Result<ExecutionPlan>
pub fn compile_with_config_and_stats_snapshot( &mut self, source: &str, config: &CompilerConfig, stats_snapshot: Option<&StatsSnapshot>, ) -> Result<ExecutionPlan>
Composable entry point that accepts a CompilerConfig.
Default-config callers should keep using compile() /
compile_with_stats_snapshot(). This entry point exists so callers can
enable the variable-ordering cost model per call without an environment
override.
Sourcepub fn compile_program(&mut self, program: &Program) -> Result<ExecutionPlan>
pub fn compile_program(&mut self, program: &Program) -> Result<ExecutionPlan>
Compile a parsed XLOG program into an execution plan.
This is useful for callers that want to inspect the AST (facts, queries, constraints) while compiling without reparsing.
Sourcepub fn compile_program_with_stats_snapshot(
&mut self,
program: &Program,
stats_snapshot: Option<&StatsSnapshot>,
) -> Result<ExecutionPlan>
pub fn compile_program_with_stats_snapshot( &mut self, program: &Program, stats_snapshot: Option<&StatsSnapshot>, ) -> Result<ExecutionPlan>
Compile a parsed XLOG program into an execution plan, optionally seeding the optimizer.
Delegates to Self::compile_program_with_config_and_stats_snapshot
with CompilerConfig::default().
Sourcepub fn compile_program_with_config_and_stats_snapshot(
&mut self,
program: &Program,
config: &CompilerConfig,
stats_snapshot: Option<&StatsSnapshot>,
) -> Result<ExecutionPlan>
pub fn compile_program_with_config_and_stats_snapshot( &mut self, program: &Program, config: &CompilerConfig, stats_snapshot: Option<&StatsSnapshot>, ) -> Result<ExecutionPlan>
Composable program-level entry point.
config is currently consumed only by the promoter when it wires the
variable-ordering cost model. With CompilerConfig::default(), the
promoter keeps the default variable order.
Sourcepub fn reset(&mut self)
pub fn reset(&mut self)
Reset the compiler state for a fresh compilation.
This creates a new lowerer, clearing any cached schemas or relation IDs from previous compilations.