pub enum RirNode {
Show 13 variants
Unit,
Scan {
rel: RelId,
},
Filter {
input: Box<RirNode>,
predicate: Expr,
},
Project {
input: Box<RirNode>,
columns: Vec<ProjectExpr>,
},
Join {
left: Box<RirNode>,
right: Box<RirNode>,
left_keys: Vec<usize>,
right_keys: Vec<usize>,
join_type: JoinType,
},
ChainJoin {
left: Box<RirNode>,
right: Box<RirNode>,
left_key: usize,
right_key: usize,
output_columns: Vec<ProjectExpr>,
fallback: Box<RirNode>,
},
GroupBy {
input: Box<RirNode>,
key_cols: Vec<usize>,
aggs: Vec<(usize, AggOp)>,
},
Union {
inputs: Vec<RirNode>,
},
Distinct {
input: Box<RirNode>,
key_cols: Vec<usize>,
},
Diff {
left: Box<RirNode>,
right: Box<RirNode>,
},
Fixpoint {
scc_id: u32,
base: Box<RirNode>,
recursive: Box<RirNode>,
delta_rel: RelId,
full_rel: RelId,
},
MultiWayJoin {
inputs: Vec<RirNode>,
slot_vars: Vec<Vec<Option<u32>>>,
output_columns: Vec<ProjectExpr>,
fallback: Box<RirNode>,
plan: Option<MultiwayPlan>,
var_order: Option<VariableOrder>,
},
TensorMaskedJoin {
mask_name: String,
schema_size: usize,
left_keys: Vec<usize>,
right_keys: Vec<usize>,
rel_index: Vec<(RelId, String)>,
head_rel_name: String,
head_rel_id: RelId,
max_active_rules: usize,
head_projection: Vec<usize>,
},
}Expand description
Relational IR node types
Variants§
Unit
A 0-arity relation containing exactly one empty tuple ({()}).
This is the identity element for joins and the natural seed for rules whose bodies
contain no positive atoms (e.g. p() :- not q().), allowing negation-only rules to
be lowered as set difference against a unit relation.
Scan
Scan a base relation
Fields
rel: RelIdRelation identifier to scan.
Filter
Filter rows by predicate
Fields
Project
Project specific columns (pass-through or computed)
Fields
columns: Vec<ProjectExpr>Output projection expressions in result-column order.
Join
Join two relations
Fields
ChainJoin
Production two-atom chain join:
head(...) :- left(..., Z, ...), right(..., Z, ...).
The executor MAY dispatch this node through a specialized
physical route. On dispatch decline, it must execute fallback,
the IR-equivalent binary join captured at promotion time.
Fields
output_columns: Vec<ProjectExpr>Output projection in head-tuple order.
GroupBy
Group by with aggregation
Fields
Union
Union multiple inputs
Distinct
Remove duplicates
Fields
Diff
Set difference (left - right)
Fields
Fixpoint
Fixpoint iteration for recursion
MultiWayJoin
A multi-way conjunctive join that the executor MAY dispatch to a
specialized physical operator (e.g. GPU WCOJ). When the dispatch
declines, the executor falls through to fallback, which is the
IR-equivalent binary-join plan captured at promotion time.
Invariant (upheld by xlog-logic::promote::promote_multiway):
executing fallback produces the same row set as a successful
specialized dispatch.
The original promoter emitted this for the triangle shape; later promoters also use it for 4-cycle and general-arity joins.
§Walker contract
Generic walkers and visitors that handle MultiWayJoin MUST be
shape-agnostic over inputs, slot_vars, and output_columns
— no walker may assume a fixed arity or a specific
variable-class layout. Only matchers/promoters whose name
carries an explicit shape qualifier (e.g.
match_multiway_triangle, try_promote_triangle) may lock to
a specific shape.
Fields
inputs: Vec<RirNode>Input scans, in physical-plan slot order. For the original
triangle promoter, this is exactly [Scan(rel_xy), Scan(rel_yz), Scan(rel_xz)] for a recognized triangle. Each input MUST be
RirNode::Scan { rel }.
slot_vars: Vec<Vec<Option<u32>>>Per-slot, per-column variable-class id. Same id across slots →
join on that variable. For the canonical triangle this is
[[Some(0), Some(1)], [Some(1), Some(2)], [Some(0), Some(2)]].
None is reserved for constant-bound or don’t-care columns;
the v1 promoter never emits None.
output_columns: Vec<ProjectExpr>Output projection in head-tuple order, identical to what the
equivalent Project { input: Join { ... } } carries. For the
triangle: [Column(0), Column(1), Column(3)]. The executor
re-validates this; a malformed or rotated projection is
treated as ineligible (no dispatch).
fallback: Box<RirNode>IR-equivalent binary-join plan. Executed verbatim on dispatch decline. Captured from the post-optimizer tree by the promoter; never synthesized.
plan: Option<MultiwayPlan>Structured route for recognized multiway shapes. K-clique cost-gated hash routes are positive plans, not promoter inability to handle the shape.
var_order: Option<VariableOrder>Optional adaptive variable-ordering decision.
None preserves legacy triangle, 4-cycle, and recursive dispatch
behavior bit-identically: dispatcher uses default leader, no
col-swap, post-kernel projection is the existing output_columns.
Some(VariableOrder) instructs the dispatcher to rotate
kernel inputs to put leader_idx at slot 0, apply
lookup_perms col-swaps, and post-project via
kernel_output_cols. output_columns is NOT consulted on
the adaptive variable-ordering path; binary-fallback consumers
still read it.
TensorMaskedJoin
Tensorized ILP super-graph join. A DLPack mask tensor selects which (body_i, body_j) → head_k rule combinations are active.