pub enum PlanNode {
Show 21 variants
Scan(ScanOp),
CustomNode(CustomOp),
Path(PathOp),
Join {
left: Box<PlanNode>,
right: Box<PlanNode>,
hash_keys: Vec<Variable>,
probe_key_domains: Vec<u64>,
probe_key_overlap_milli: Vec<u64>,
rhs_hostable_keys: Arc<[Variable]>,
meta: JoinMeta,
},
LeftJoin {
left: Box<PlanNode>,
right: Box<PlanNode>,
hash_keys: Vec<Variable>,
early_filter: Option<Expression>,
residual_filter: Option<Expression>,
probe_key_domains: Vec<u64>,
probe_key_overlap_milli: Vec<u64>,
meta: LeftJoinMeta,
},
Filter {
inner: Box<PlanNode>,
early: Option<Expression>,
residual: Option<Expression>,
exists: Vec<ExistsClause>,
one_to_one: bool,
},
Union {
left: Box<PlanNode>,
right: Box<PlanNode>,
},
Unit,
Values(ValuesOp),
NamedGraphs {
variable: Variable,
produced_row_count_estimate: u64,
},
NamedGraphExists {
graph: EncodedTerm,
},
JoinGraphVar {
inner: Box<PlanNode>,
graph_var: Variable,
active_var: Variable,
},
Extend {
inner: Box<PlanNode>,
variable: Variable,
expression: Expression,
const_strings: Vec<(StrHash, String)>,
const_blobs: Vec<(StrHash, Vec<u8>)>,
},
Slice {
inner: Box<PlanNode>,
start: u64,
length: Option<u64>,
},
Distinct {
inner: Box<PlanNode>,
columns: Vec<Variable>,
},
Sort {
inner: Box<PlanNode>,
keys: Vec<SortKey>,
},
Group {
inner: Box<PlanNode>,
variables: Vec<Variable>,
aggregates: Vec<(Variable, AggregateExpression)>,
const_strings: Vec<(StrHash, String)>,
const_blobs: Vec<(StrHash, Vec<u8>)>,
},
DomainCounts {Show 14 fields
kind: DomainScanKind,
constraints: Vec<EncodedTerm>,
constraint_multiplicity: Vec<u64>,
constraint_var: Option<Variable>,
head: Variable,
count: Variable,
dead: Option<Variable>,
count_star: bool,
count_distinct: bool,
graph_name: Option<EncodedTerm>,
graph_filter: Option<GraphFilter>,
merge_default_graph: bool,
iri_only: bool,
produced_row_count_estimate: u64,
},
HeadCounts {
kind: HeadScanKind,
total: bool,
counted: Variable,
group: Option<Variable>,
count: Variable,
graph_name: Option<EncodedTerm>,
graph_filter: Option<GraphFilter>,
iri_only: bool,
produced_row_count_estimate: u64,
},
PatternCount {
pattern: EncodedTriplePattern,
subject: Option<Variable>,
predicate: Option<Variable>,
object: Option<Variable>,
count: Variable,
count_star: bool,
counted: Option<Variable>,
graph_filter: Option<GraphFilter>,
merge_default_graph: bool,
produced_row_count_estimate: u64,
},
SubSelect(SubSelectOp),
}Expand description
Physical plan tree after sparopt + Waratah lowering.
Variants§
Scan(ScanOp)
Scan one triple pattern on a hexastore axis.
CustomNode(CustomOp)
Plugin-defined custom operator (geo_scan from the geosparql
plugin in v1): an opaque leaf or wrapper the planner/executor plugins
own. Core passes treat it as a leaf producing variables.
Path(PathOp)
SPARQL 1.1 property path (*, +, ?, |, !, nested /).
Join
Inner join of two sub-plans.
Fields
probe_key_domains: Vec<u64>Probe-side distinct-value estimate per hash key, aligned with
hash_keys (the probe is this join’s right arm — pushed key
lists filter it). Written at finalize/refinalize (recomputed for
the current seating, like strategy), read at runtime by the
pushdown coverage check in PushedKeyVals::combine: a list covering
~the probe’s whole key space selects nothing and is skipped, so
the scan runs unbound and the join applies the same predicate
downstream. Advisory only: 0/absent = unknown → keep pushing.
Never read by the estimator — costing keeps deriving from the
profile (join_key_domain_for_node).
probe_key_overlap_milli: Vec<u64>Per-key vocabulary containment stamp, aligned with hash_keys
(milli-scaled |driver vocab ∩ probe vocab| / driver vocab,
estimate_vocabulary_overlap): how much of the probe’s key
space a pushed list can actually reach. Scales the runtime
coverage verdict — a cross-population list (candidate ops,
unrelated predicates’ vocabularies) prunes the probe even when
its length saturates the domain count, which the bare count
rule cannot see. 1000/absent = full containment (the count
rule’s sound home) — every degrade path lands here, making
1000 the byte-identical historical behavior.
rhs_hostable_keys: Arc<[Variable]>Variables the right (probe) subtree can consume as pushed
allow-list keys: hosted in an S/P/O (or graph) slot of a scan
leaf reachable through push-transparent containers — the exact
topology probe_scan_has_key walks (“the modeled
push-reachability topology”) — plus custom-op outputs (the
keyed regime consumes pushed values directly). Stamped by
[stamp_rhs_hostable_keys] at the finalize/refinalize sites,
from the FINAL right arm — after the seating swap and the
arm-reshaping passes (grounding removes a hosted slot; graph
compose adds one) — unlike the key-aligned stamps, which are
taken before the reshaping. A set, not a key-aligned array:
hostability does
not depend on key order, so
reorder_hash_keys_by_probe_return never invalidates it.
Consumed at runtime by the subtree push gate
(PushGate::Hostable): a hash key not in this set has no
scan leaf to filter anywhere in the probe subtree, so pushing
it is dead wire weight, and an ancestor entry outside this
set has no consumer below this join.
LeftJoin
SPARQL OPTIONAL (left outer join).
Fields
residual_filter: Option<Expression>AlwaysResolve residual (Diff-once after windowed string resolve).
probe_key_domains: Vec<u64>Probe-side distinct-value estimate per hash key, aligned with
hash_keys (the probe is this OPTIONAL’s right arm — pushed key
lists filter it). Written at finalize/refinalize (recomputed for
the current seating, like strategy), read at runtime by the
pushdown coverage check in PushedKeyVals::combine: a list covering
~the probe’s whole key space selects nothing and is skipped, so
the scan runs unbound and the join applies the same predicate
downstream. Advisory only: 0/absent = unknown → keep pushing.
Never read by the estimator — costing keeps deriving from the
profile (join_key_domain_for_node).
probe_key_overlap_milli: Vec<u64>Per-key vocabulary containment stamp, aligned with hash_keys
(see the Join variant’s field for the full contract; the
OPTIONAL probe’s runtime path consumes it identically).
meta: LeftJoinMetaRow-count annotations (no strategy — the executor treats every LeftJoin probe identically; runtime key delivery is dynamic).
Filter
SPARQL FILTER.
Fields
exists: Vec<ExistsClause>Top-level EXISTS / NOT EXISTS conjuncts, lowered separately.
Empty is an ordinary FILTER. HAVING (Filter over Group) never
populates this — those expressions stay in early/residual and
are rejected by [split_filter].
one_to_one: boolInner demand may follow caller n instead of crate::query::tunables::SCAN_BATCH.
Stamped by [crate::iri_facts::derive_iri_facts] when every kept
conjunct is isIRI(?v) / isURI(?v) and there is no EXISTS
clause. The residual still runs; OpenNode pages the child at n
because this shape is expected to keep every inner row.
Union
SPARQL UNION (multiset / bag union of solution mappings).
Unit
SPARQL empty group { }: one solution with no bindings (join identity).
Values(ValuesOp)
SPARQL VALUES (inline table).
NamedGraphs
Execute-time named-graph catalog (GRAPH ?g with no FROM NAMED).
Enumerated FROM NAMED uses Self::Values instead (no catalog RPC).
Estimated rows are StatsProfile::named_graph_count when a cluster
profile is loaded; otherwise [NAMED_GRAPHS_ESTIMATED_ROWS].
Fields
variable: VariableVariable bound to each catalog graph IRI (?g).
NamedGraphExists
Execute-time catalog membership for empty GRAPH <iri> { } when the
named window is engine-default (no FROM NAMED). One empty row if
graph is Present; zero rows otherwise. FROM NAMED stays plan-time.
Fields
graph: EncodedTermGrounded named-graph IRI to look up.
JoinGraphVar
SPARQL Join(eval(P), { ?g → μ(?g_active) }) after GRAPH ?g { P }
when P uses ?g as a triple/OPTIONAL/FILTER variable.
Inner scans project the active graph as active_var; SPARQL ?g stays
a normal term variable. Unbound graph_var is filled from active_var
(OPTIONAL miss); unequal bound values drop the row.
Fields
graph_var: VariableSPARQL GRAPH variable (?g).
active_var: VariableHidden active-graph column projected from inner G slots.
Extend
SPARQL BIND / non-aggregate SELECT (expr AS ?v) (Extend).
Fields
variable: VariableVariable introduced by the extend.
expression: ExpressionExpression evaluated per row.
const_strings: Vec<(StrHash, String)>Plan-carried const seed entries for EVERY constant position of
expression — top level and nested (COALESCE fallbacks, IF
branches, function arguments). Collected at plan finalization
([attach_const_seeds]); installed into the executing cache at
op entry (execute_extend), the execute_values contract:
hash-only encodings (IRIs, long strings, plugin-encoded
geometry) decode from cache entries a fresh mint would not
have — inline-encoded constants (numerics, small strings) mint
no entries at all — and query constants are not store data,
while an arm workspace inherits nothing, so the entries must
ride the op that mints them.
Slice
SPARQL LIMIT / OFFSET (Slice).
Fields
Distinct
SPARQL DISTINCT on the SELECT projection (first-seen row wins).
Fields
columns: Vec<Variable>Variables the DEDUP DECIDES on (first-seen key-tuple wins). NOT the output projection: the runtime carries every inner column through, so two rows differing only in a non-key column collapse to the first one (its non-key values win). The SELECT list narrows the width later, in the projection.
Sort
SPARQL ORDER BY (after Distinct, before Slice).
Fields
Group
SPARQL GROUP BY plus aggregates (HAVING is a Self::Filter above).
Output columns are the grouping keys plus each aggregate’s result variable. Inner columns that are not keys exist only as aggregator inputs and are not projected.
Fields
aggregates: Vec<(Variable, AggregateExpression)>Aggregate result variable and expression (including COUNT(*)).
const_strings: Vec<(StrHash, String)>Plan-carried const seed entries for every constant position of
every aggregate-argument expression (same contract as
Self::Extend’s fields): the fold evaluates argument
expressions on the encoded path and a const argument’s mint
escapes into the group value. Installed at
resolve_aggregate_args entry, above its variable-driven
early return — a const-only argument has an empty variable
list and would otherwise skip its own seeding.
DomainCounts
Group-eliminating count scan: per-(constraint, head) run lengths
from one DomainScanCounts rpc, replacing Group { Scan { .. } }
for the lone-COUNT shape (Group elimination — no rows are streamed
and no compute-side aggregation runs).
Output columns are exactly [head, count] — the replaced Group’s
schema (its single key plus the aggregate’s alias) — so Extend
alias passthroughs, HAVING filters, and Sorts above keep working.
The counted variable is never emitted: the partition supplies its
per-head multiplicity as count.
Fields
kind: DomainScanKindWhich constraint/head slot family this scan is.
constraints: Vec<EncodedTerm>Plan-time constraint term list (one pattern constant, folded sameTerm, or a VALUES allow-list). Distinct: the count RPC uniques its constraint list. Key-sorted (encoded key bytes), matching the order every domain walker visits constraints in.
constraint_multiplicity: Vec<u64>How many VALUES rows carried each [Self::constraints] term.
Parallel to that list. A lone pattern constant is [1]. The
materializer multiplies each hit’s run length by the factor for
hit.constraint. The two-key rewrite is not taken when this
column has an UNDEF, or when another VALUES column is also a
scan slot (that column is a join key, not a scalar).
constraint_var: Option<Variable>When the constraint slot is also a GROUP BY key (VALUES ?p or
grounded-kept predicate), the variable name — omitted for the
one-key ?s :p ?o GROUP BY ?o shape.
head: VariableGroup-key variable — the kind’s head slot (or second key in the two-key VALUES shape).
count: VariableCount result variable — the aggregate’s alias.
dead: Option<Variable>Variable on the kind’s dead slot, when the triple named one.
Explain reconstructs COUNT(?dead) and the source triple from
this. The count RPC never returns the slot.
count_star: boolCOUNT(*) rather than COUNT(?dead). The run length is the
solution count either way; explain needs the source spelling.
count_distinct: boolCOUNT(DISTINCT ?dead): the RPC counts distinct slot-2 terms per
run, so each hit’s count is already the distinct cardinality and
VALUES multiplicity must not scale it. The shortcut never serves
the graph-count mode (an unbound ?g refuses the rewrite).
graph_name: Option<EncodedTerm>Bound graph name, when the query’s graph window is a single
grounded graph (GRAPH <iri>).
graph_filter: Option<GraphFilter>Residual graph window pushed with the scan.
merge_default_graph: boolRDF-merge default graph (--default-union / multi-FROM). The
count RPC uniques S/P/O and skips extra G. The graph filter above
is left as the scan planned it.
iri_only: boolPlanner-derived FILTER(isIRI(?head)) pushdown.
Set by [crate::iri_facts::derive_iri_facts] when an ancestor
conjunct is isIRI of the head (the group key). Non-IRI heads
are their own groups, so dropping them in the count RPC matches
filtering those groups afterwards. The conjunct stays in the plan.
HeadCounts
Group-eliminating head-count leaf (eliminate_head_counts_groups):
a whole-CF AxisHeadScanCounts call
replaces the Group — either the TOTAL shape (ungrouped
COUNT(DISTINCT ?head): one integer for the whole column family) or
the PER_HEAD shape (GROUP BY ?head COUNT(DISTINCT ?slot1): one
(group, count) row per slot-0 head, e.g. TSG per-class subject
counts). Head counts have no constraint slot, so there is no anchor
machinery and no VALUES-facet form.
Fields
kind: HeadScanKindWhich axis-local column family this scan walks.
total: booltrue = TOTAL mode (the distinct slot-0 head count of the whole
CF as one row); false = PER_HEAD mode (one row per head).
counted: VariableThe distinct-counted variable: the CF’s slot-0 head (TOTAL) or slot-1 term (PER_HEAD). Never broadcast by the RPC in either mode.
group: Option<Variable>PER_HEAD group-key variable — the CF’s slot-0 head. None in
TOTAL mode (nothing is grouped).
count: VariableCount result variable — the aggregate’s alias.
graph_name: Option<EncodedTerm>Bound graph name, when the query’s graph window is a single
grounded graph (GRAPH <iri>).
graph_filter: Option<GraphFilter>Residual graph window pushed with the scan.
PatternCount
Group-eliminating bag-count leaf (eliminate_pattern_count_groups):
ungrouped COUNT(*) / bag COUNT(?v) over a single BGP. One
CountPattern RPC returns the visible
Put cardinality; no solution rows cross the wire. Runs after the
head/domain eliminate passes so facet and COUNT(DISTINCT …) shapes
keep those leaves.
Fields
pattern: EncodedTriplePatternEncoded ground slots of the source scan (None = unbound).
count: VariableCount result variable — the aggregate’s alias.
graph_filter: Option<GraphFilter>Residual graph window pushed with the scan.
SubSelect(SubSelectOp)
SPARQL nested SELECT (SubSelect) — an opaque, independently
evaluated query boundary.
The inner plan is lowered and executed on its own; only variables
(the subselect’s SELECT list) cross the boundary and join with the
enclosing group. Non-projected inner names are renamed with a random
per-subselect scope token at lowering time (sq_<16 random chars>_),
so same-named outer variables can never collide with them in join
keys, filters, or liveness.
Implementations§
Source§impl PlanNode
impl PlanNode
Sourcepub fn inner_variables(&self) -> Vec<Variable>
pub fn inner_variables(&self) -> Vec<Variable>
Columns this subtree produces. This is the structural variable list
(Scan slot names, path ends, VALUES columns, group outputs) — computed
bottom-up WITHOUT consulting liveness marks, so it is safe to call
during the liveness walk itself (unlike Self::variables, which
filters by is_live and would read the marks being rewritten).
Sourcepub fn output_vars(&self) -> OutputVars
pub fn output_vars(&self) -> OutputVars
Boundness of variables produced by this subtree.
Sourcepub fn variables(&self) -> Vec<Variable>
pub fn variables(&self) -> Vec<Variable>
Variables produced by this subtree (always-bound first, then maybe-unbound).
Sourcepub fn produced_row_count_estimate(&self) -> u64
pub fn produced_row_count_estimate(&self) -> u64
Estimated cardinality for costing (best-effort).
Sourcepub fn as_scan_mut(&mut self) -> Option<&mut ScanOp>
pub fn as_scan_mut(&mut self) -> Option<&mut ScanOp>
Mutable Self::as_scan — the fetch-once stamp pass writes
ScanOp::fetch_once through this (its sole writer).
Sourcepub fn as_broadcast_scan(&self) -> Option<&ScanOp>
pub fn as_broadcast_scan(&self) -> Option<&ScanOp>
Scan under a chain of FILTER / BIND wrappers (inner-join Broadcast).
Sourcepub fn as_union(&self) -> Option<&PlanNode>
pub fn as_union(&self) -> Option<&PlanNode>
Union under a chain of FILTER / BIND wrappers (scan↔Union driver swap).
Sourcepub fn as_dependent_path(&self) -> Option<&PathOp>
pub fn as_dependent_path(&self) -> Option<&PathOp>
Path under a chain of FILTER / BIND wrappers (dependent Broadcast).
Sourcepub fn as_extend_path(&self) -> Option<&PathOp>
pub fn as_extend_path(&self) -> Option<&PathOp>
Path under BIND (Extend) only — not FILTER.
Slice may push OFFSET+LIMIT through BIND (1:1). FILTER can reject
rows, so it must not use this helper.
Sourcepub fn as_subselect(&self) -> Option<&SubSelectOp>
pub fn as_subselect(&self) -> Option<&SubSelectOp>
If this node is a nested SELECT boundary, return it.
Trait Implementations§
impl StructuralPartialEq for PlanNode
Auto Trait Implementations§
impl Freeze for PlanNode
impl !RefUnwindSafe for PlanNode
impl Send for PlanNode
impl Sync for PlanNode
impl Unpin for PlanNode
impl UnsafeUnpin for PlanNode
impl !UnwindSafe for PlanNode
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request§impl<L> LayerExt<L> for L
impl<L> LayerExt<L> for L
§fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
Layered].