Skip to main content

laminar_core/compiler/
mod.rs

1//! Plan compiler infrastructure for Ring 0 event processing.
2//!
3//! This module provides the foundation for compiling `DataFusion` logical plans
4//! into native functions that operate on a fixed-layout row format.
5//!
6//! # Components
7//!
8//! - [`row`]: Fixed-layout [`EventRow`] format with zero-copy field access
9//! - [`bridge`]: [`RowBatchBridge`] for converting rows back to Arrow `RecordBatch`
10//! - [`policy`]: [`BatchPolicy`] and [`BackpressureStrategy`] for bridge configuration
11//! - [`pipeline_bridge`]: Ring 0 / Ring 1 SPSC bridge with watermark-aware batching
12//! - [`event_time`]: Schema-aware event time extraction for compiled queries
13//! - [`metrics`]: Query lifecycle types (always available, not JIT-gated)
14//!
15//! ## JIT Compilation (requires `jit` feature)
16//!
17//! - `error`: Error types and compiled function pointer wrappers
18//! - `expr`: Cranelift-based expression compiler
19//! - `fold`: Constant folding pre-pass
20//! - `jit`: Cranelift JIT context management
21//! - `pipeline`: Pipeline types and compiled pipeline wrapper
22//! - `extractor`: Pipeline extraction from `DataFusion` logical plans
23//! - `pipeline_compiler`: Cranelift codegen for fused pipelines
24//! - `cache`: Compiler cache for compiled pipelines
25//! - `fallback`: Fallback mechanism for uncompilable pipelines
26//! - `query`: `StreamingQuery` lifecycle management
27//! - `breaker_executor`: Compiled stateful pipeline bridge (Ring 1 operator wiring)
28
29pub mod batch_reader;
30pub mod bridge;
31pub mod compilation_metrics;
32pub mod event_time;
33pub mod metrics;
34pub mod pipeline_bridge;
35pub mod policy;
36pub mod row;
37
38#[cfg(feature = "jit")]
39pub mod breaker_executor;
40#[cfg(feature = "jit")]
41pub mod cache;
42#[cfg(feature = "jit")]
43pub mod error;
44#[cfg(feature = "jit")]
45pub mod expr;
46#[cfg(feature = "jit")]
47pub mod extractor;
48#[cfg(feature = "jit")]
49pub mod fallback;
50#[cfg(feature = "jit")]
51pub mod fold;
52#[cfg(feature = "jit")]
53pub mod jit;
54#[cfg(feature = "jit")]
55pub mod orchestrate;
56#[cfg(feature = "jit")]
57pub mod pipeline;
58#[cfg(feature = "jit")]
59pub mod pipeline_compiler;
60#[cfg(feature = "jit")]
61pub mod query;
62
63pub use batch_reader::BatchRowReader;
64pub use bridge::{BridgeError, RowBatchBridge};
65pub use compilation_metrics::{CacheSnapshot, CompilationMetrics, MetricsSnapshot};
66pub use event_time::{EventTimeConfig, RowEventTimeExtractor};
67pub use metrics::{
68    QueryConfig, QueryError, QueryId, QueryMetadata, QueryMetrics, QueryState, StateStoreConfig,
69    SubmitResult,
70};
71pub use pipeline_bridge::{
72    create_pipeline_bridge, BridgeConsumer, BridgeMessage, BridgeStats, BridgeStatsSnapshot,
73    PipelineBridge, PipelineBridgeError, Ring1Action,
74};
75pub use policy::{BackpressureStrategy, BatchPolicy};
76pub use row::{EventRow, FieldLayout, FieldType, MutableEventRow, RowError, RowSchema};
77
78#[cfg(feature = "jit")]
79pub use error::{CompileError, CompiledExpr, ExtractError, FilterFn, MaybeCompiledExpr, ScalarFn};
80#[cfg(feature = "jit")]
81pub use expr::ExprCompiler;
82#[cfg(feature = "jit")]
83pub use jit::JitContext;
84
85// Plan Compiler Core types
86#[cfg(feature = "jit")]
87pub use cache::CompilerCache;
88#[cfg(feature = "jit")]
89pub use extractor::{ExtractedPlan, PipelineExtractor};
90#[cfg(feature = "jit")]
91pub use fallback::ExecutablePipeline;
92#[cfg(feature = "jit")]
93pub use pipeline::{
94    CompiledPipeline, Pipeline, PipelineAction, PipelineBreaker, PipelineFn, PipelineId,
95    PipelineStage, PipelineStats,
96};
97#[cfg(feature = "jit")]
98pub use pipeline_compiler::PipelineCompiler;
99
100// Streaming Query Lifecycle
101#[cfg(feature = "jit")]
102pub use query::{StreamingQuery, StreamingQueryBuilder};
103
104// SQL Compiler Orchestrator
105#[cfg(feature = "jit")]
106pub use orchestrate::{compile_streaming_query, CompiledStreamingQuery};
107
108// Compiled Stateful Pipeline Bridge
109#[cfg(feature = "jit")]
110pub use breaker_executor::{BreakerExecutor, CompiledQueryGraph, Ring1Operator};