pub struct ScanOp {Show 19 fields
pub pattern: EncodedTriplePattern,
pub subject: Option<Variable>,
pub predicate: Option<Variable>,
pub object: Option<Variable>,
pub graph: Option<Variable>,
pub produced_row_count_estimate: u64,
pub ancestor_push_return_bound: Option<u64>,
pub broadcasted: Option<(Variable, PatternSlot)>,
pub fetch_once: Option<u64>,
pub graph_filter: Option<GraphFilter>,
pub grounded: Vec<(Variable, PatternSlot)>,
pub merge_default_graph: bool,
pub marks: Vec<(Variable, Liveness, BagMark)>,
pub domain_scan: Option<DomainScanKind>,
pub head_scan: Option<HeadScanKind>,
pub domain_counts: Option<DomainScanKind>,
pub head_scan_counts: Option<HeadScanKind>,
pub iri_only: Vec<Variable>,
pub eager: Vec<SlotComparison>,
/* private fields */
}Expand description
One triple pattern resolved to an encoded scan plus its variable slots.
Fields§
§pattern: EncodedTriplePatternEncoded ground slots; None slots are variables.
subject: Option<Variable>Variable bound by the subject slot, if any.
predicate: Option<Variable>Variable bound by the predicate slot, if any.
object: Option<Variable>Variable bound by the object slot, if any.
graph: Option<Variable>Variable bound by the graph slot (GRAPH ?g), if any.
produced_row_count_estimate: u64Estimated cardinality from the local sketch cache (1 when unknown).
ancestor_push_return_bound: Option<u64>Return-row bound an ANCESTOR join’s broadcast push imposes on this
scan: the claimer’s pushed value list filters this scan’s reads in
every seating of the joins below the claimer, so the pushed-return
estimate (pushed_scan_return_bound) is the scan’s true whole read
there — a number this scan cannot recompute locally (the claimer’s
driver domain lives in a subtree above it). The round-entry recost
bounds Self::produced_row_count_estimate at this value so inner
seating decisions price the bounded read, not catalog size (the
transects defect: an inner join re-pricing an ancestor-pushed arm
at its ~8M whole read instead of the ~1.5k the push returns).
Joins BELOW the claimer read it as an orientation-invariant driver
term (a foreign claim for them — driver_whole_read_rows prices the
bounded cell). The claimer’s OWN next-round reads are
ownership-aware: the recost keeps the cell at the bound (correct
for the probe road, produced, EXPLAIN), but the seating’s driver
term prices the intrinsic — the probe road’s clamped return is not
a driving read (the tenant-union flip: an own-claim cell of ~80
priced a 50k-catalog arm as a phantom-cheap driver).
Writers: clamp_broadcast_probe_estimates (re-derived each round
against the claimer’s settled driver — one round stale, the
pipeline’s standard epistemic class) and the claim walk
claim_broadcast_probe, which stamps mark and bound as a pair so
a fresh claim carries its bound immediately. Sole
remover: clear_broadcast_marks — this bound’s lifetime is exactly
the broadcasted claim mark’s.
broadcasted: Option<(Variable, PatternSlot)>Runtime allow-list hint: join key probed on this slot (EXPLAIN /
costing only; execution still uses left solution values / runtime
PushedKeyVals). One variable, one slot — the wire filter is still a
single BroadcastFilter. Sole writer: restamp_broadcast_marks
(pre-order claim, first/outermost claim wins); sole remover: the
swap-time clear_broadcast_marks in refinalize_joins.
fetch_once: Option<u64>Plan-time fetch-once stamp: the priced trigger
decided this probe arm’s per-page key-list broadcast costs more than
MARGIN × one whole read, so the executor takes the built
(Unfiltered-shaped) arm from page 1 — it never enters
join_keys_scan_filter, skips the coverage machinery, and creates
no memo entries (the built table is the reuse structure). The
carried value is the UNCLAMPED arm row estimate the predicate
priced against (estimate_unclamped_scan_rows — NOT the push-clamped
produced_row_count_estimate, which answers what the arm returns
UNDER pushes): the runtime bail-out compares the drained rows
against exactly this number. Sole writer: restamp_fetch_once,
after the last seating round; readers: execute_join’s scan branch,
the concurrent-star probe fetch (eager path only — a
demand-bounded LIMIT pull must not over-drain), and
fetch_whole’s publish gate. Pure transport hint: rows are
identical either way.
graph_filter: Option<GraphFilter>Residual G allow-list or block-list (not a PatternSlot).
grounded: Vec<(Variable, PatternSlot)>Plan-time grounded slots: variable names stay for projection; the
encoded term lives in pattern. Same variable may appear twice
(?b subject and object on ?b a ?b).
merge_default_graph: boolSPARQL default-graph RDF merge. Set when [GraphScope::Default] uses
DefaultGraphWindow::AllGraphs or DefaultGraphWindow::Allow.
Storage emits each S/P/O once and rewrites G to DefaultGraph (not
user-visible: this scan does not project G). Never set inside GRAPH.
marks: Vec<(Variable, Liveness, BagMark)>Per-slot liveness and bag marks. Empty = not yet annotated (every slot
name behaves as live bag-sensitive — see ScanOp::slot_mark).
domain_scan: Option<DomainScanKind>Execute via the constrained DomainScan RPC (known slot-0 constraint
→ distinct slot-1 head terms) instead of a triple ScanPattern.
head_scan: Option<HeadScanKind>Execute via the bare AxisHeadScan RPC (distinct slot-0 head terms of
one whole CF) instead of a triple ScanPattern. Mutually exclusive
with ScanOp::domain_scan; the liveness gates guarantee it.
domain_counts: Option<DomainScanKind>Execute via the DomainScanCounts RPC (per-(constraint, head) run
lengths) instead of a triple ScanPattern: the bag consumer — a live
bag-SENSITIVE head slot whose values a plain scan would stream whole.
Run-length pairs reconstruct that identical multiset client-side.
Mutually exclusive with ScanOp::domain_scan and ScanOp::head_scan.
head_scan_counts: Option<HeadScanKind>Execute via the AxisHeadScanCounts RPC instead of a triple
ScanPattern: TOTAL (the head slot is counted-distinct and the
head count is the group result) or PER_HEAD (the head is a live
group key, the slot-1 variable counted-distinct). Which of the two a
scan serves follows from the marks — see ScanOp::head_count_is_total.
Mutually exclusive with the other scan rewrites.
iri_only: Vec<Variable>Variables the planner proved IRI-valued via kept FILTER(isIRI(?x))
conjuncts (see [crate::iri_facts]). Pushed to partitions as an S/O
first-byte pre-filter via Self::iri_only_slots; the filter
conjunct itself always stays in the plan — in the OPTIONAL case it is
what eliminates the unbound-extension rows.
eager: Vec<SlotComparison>Slot comparisons derived from kept FILTER(?v OP literal) conjuncts
above this scan. The one plan-side record of these conjuncts; the
partition’s wire list is derived from it at request build
(Self::pushed_comparisons). The conjunct stays in the plan and
remains authoritative: both the partition and the compute-side eager
filter drop only rows the comparison provably fails and keep every
row they cannot decide. Empty for scans with no such filter. See
[crate::scan_comparisons] and [crate::scan_eager].
Implementations§
Source§impl ScanOp
impl ScanOp
Sourcepub fn for_plugin_pattern(
pattern: EncodedTriplePattern,
subject: Variable,
object: Variable,
graph: Option<Variable>,
graph_filter: Option<GraphFilter>,
merge_default_graph: bool,
produced_row_count_estimate: u64,
) -> Self
pub fn for_plugin_pattern( pattern: EncodedTriplePattern, subject: Variable, object: Variable, graph: Option<Variable>, graph_filter: Option<GraphFilter>, merge_default_graph: bool, produced_row_count_estimate: u64, ) -> Self
Build a minimal scan for a plugin-minted plan (the text plugin’s subject-mode predicate scan): variables bound in the two named slots, every mark / stamp / estimate knob at its fresh default.
Not for the SPARQL lowering path — lower_pattern’s constructor
carries the dataset scoping, sketch estimates, and join-domain
classification a lowered BGP needs. A plugin-minted scan reads at
the query snapshot like every scan; the graph-scope fields must be
copied from a sibling scan’s ScanOp::applied_graph (or the
dataset fallback, applied_default_graph) so the minted scan sees
exactly the graphs the surrounding BGP sees.
Sourcepub fn applied_graph(&self) -> AppliedGraph
pub fn applied_graph(&self) -> AppliedGraph
The applied graph scope this scan reads: the four fields that decide which graphs it may see. Ground truth for its plan position — plugin-minted scans copy this from a sibling scan so their visibility matches the surrounding BGP.
Sourcepub fn variables(&self) -> Vec<Variable>
pub fn variables(&self) -> Vec<Variable>
Variables this scan produces for downstream operators (live names only),
in subject/predicate/object/graph order. Dead+Counted slots are omitted here
but appear in Self::materialized_variables / [EncodedSolutions::from_scan].
Sourcepub fn output_slots(&self) -> ScanOutputSlots
pub fn output_slots(&self) -> ScanOutputSlots
Single derivation of this scan’s output slot structure — see
[ScanOutputSlots] for who consumes which field. Every former
independent slot walk builds on this, so the page schema, the memo
key, and from_scan’s row filter stay in agreement by construction.
Sourcepub fn materialized_variables(&self) -> Vec<Variable>
pub fn materialized_variables(&self) -> Vec<Variable>
Live and Counted slot names in S/P/O/G order — schema for scan pages built
by [EncodedSolutions::from_scan]. Only Dead slots are excluded:
the run-length RPC stands in for counted columns on the count path,
but a plain scan still broadcasts the values, and a counted-distinct slot
must stay resolvable compute-side whenever the count rewrite does not
serve it.
Derived from the single ScanOp::output_slots walk.
Sourcepub fn omitted_slots(
&self,
effective: &EncodedTriplePattern,
allow_dead: bool,
) -> u8
pub fn omitted_slots( &self, effective: &EncodedTriplePattern, allow_dead: bool, ) -> u8
Response slots this scan can ask the partition to leave empty
(ScanPatternRequest.omitted_slots).
A slot is omitted only when the receiver can put back exactly the term an unomitted response would have carried, in one of two ways:
- Bound: the effective pattern binds the slot — a constant in the query, or a term the executor just pinned with a broadcast push. Reassembly returns that term, so the row is identical to a full one and a cursor built from it encodes the same key. This bit is safe on every request shape: unary pages, windowed pulls, and resumable streams alike.
- Dead (
allow_deadonly): the slot carries a variable nothing downstream reads — dropped, and not part of a repeated-variable row filter. Reassembly returns the counted-presence sentinel instead of the stored term, which is a value change: a cursor built from such a row would encode a wrong key. Callers therefore setallow_deadonly on requests whose rows can never become astart_after(a drain with no cursor that restarts on retry), never on paged or resumable ones.
effective must be the pattern the request actually carries, not
self.pattern: grounding rewrites slots at execution time.
Sourcepub fn repeat_slot_pairs(&self) -> Vec<(u8, u8)>
pub fn repeat_slot_pairs(&self) -> Vec<(u8, u8)>
Same-name slot pairs in S/P/O/G order as (first, later) slot
indices (0=S, 1=P, 2=O, 3=G) — the identity of
[EncodedSolutions::from_scan]’s repeated-variable row filter.
Part of the scan memo key: a cached table bakes the filter in, so
?a :p ?a and ?a :p ?dead must never share an entry even when
their live column lists coincide (materialized_variables
deduplicates by name).
Derived from the single ScanOp::output_slots walk.
Sourcepub fn slot_variables(&self) -> Vec<Variable>
pub fn slot_variables(&self) -> Vec<Variable>
Slot names in S/P/O/G order, including dead repeats (?x ?p ?x).
Sourcepub fn slot_mark(&self, variable: &Variable) -> Option<SlotMark>
pub fn slot_mark(&self, variable: &Variable) -> Option<SlotMark>
Full mark for a slot name. None when variable is not a slot.
Sourcepub fn bag_mark(&self, variable: &Variable) -> Option<BagMark>
pub fn bag_mark(&self, variable: &Variable) -> Option<BagMark>
Bag mark for a slot. None when variable is not a slot on this scan.
Sourcepub fn is_dropped(&self, variable: &Variable) -> bool
pub fn is_dropped(&self, variable: &Variable) -> bool
Whether variable is a dead slot whose column may be omitted. Not
relevant for a slot a pushed comparison reads (see
Self::comparison_reads).
Sourcepub fn is_counted(&self, variable: &Variable) -> bool
pub fn is_counted(&self, variable: &Variable) -> bool
Counted slot whose row multiplicity is required (COUNT(?v) or plain
COUNT(*)). The column is omitted from live output; a partition-side
run-length row count stands in for it.
Sourcepub fn is_counted_distinct(&self, variable: &Variable) -> bool
pub fn is_counted_distinct(&self, variable: &Variable) -> bool
Counted slot whose distinct term cardinality is all that is required
(COUNT(DISTINCT ?v) over a dead slot, or COUNT(DISTINCT ?g) over
the graph slot). The column is omitted from live output; the
partition counts distinct terms per run instead.
Sourcepub fn head_count_is_total(&self, kind: HeadScanKind) -> bool
pub fn head_count_is_total(&self, kind: HeadScanKind) -> bool
Whether this scan’s head_scan_counts annotation serves the TOTAL
shape (head slot counted-distinct, group result = the whole CF’s
distinct head count) rather than PER_HEAD (head is a live group
key; each hit counts distinct slot-1 terms under it).
Sourcepub fn domain_count_mode(&self) -> DomainCountMode
pub fn domain_count_mode(&self) -> DomainCountMode
What one run-count increment of this scan’s domain_counts RPC
represents, derived from the marks: a counted-distinct graph slot is
DomainCountMode::DistinctGraphs, a counted-distinct S/P/O slot is
DomainCountMode::DistinctTerms, everything else is the bag
DomainCountMode::Rows.
Sourcepub fn collapse_keys(&self) -> Vec<Variable>
pub fn collapse_keys(&self) -> Vec<Variable>
Live bag-insensitive columns (collapse keys). Empty if this scan must not collapse (counted slot in either mode — a count RPC stands in for it, or the generic consumer needs the un-collapsed rows — a live Sensitive slot, or a domain rewrite).
Sourcepub fn will_collapse(&self) -> bool
pub fn will_collapse(&self) -> bool
Compute-side DISTINCT ON collapse keys (not used by domain / head
scans).
Sourcepub fn is_iri_only(&self, variable: &Variable) -> bool
pub fn is_iri_only(&self, variable: &Variable) -> bool
Whether variable carries a planner-derived IRI-only fact
(FILTER(isIRI(?x)) conjunct proved above this scan).
Sourcepub fn iri_only_slots(&self) -> IriOnlyMask
pub fn iri_only_slots(&self) -> IriOnlyMask
S/O pushdown flags for scan RPCs. G facts never ride the wire (compute filters G itself), and P is always an IRI by encoding.
Sourcepub fn pushed_comparisons(&self) -> &[SlotComparison]
pub fn pushed_comparisons(&self) -> &[SlotComparison]
The subset of Self::eager to place on the scan request’s
comparisons field.
eager is the plan’s one record of the filter conjuncts; the wire
field is a request-time view of it, not a second plan list. The view
is empty for a specialized rewrite (domain / head / counts): those scans
answer from their own RPC and never run the pattern walk the field
feeds. A graph-slot comparison never reaches eager — the planner
rejects it and the wire is S/P/O only — and the assertion below makes
a future writer that gets that wrong fail loudly here instead of
splitting into an encoder rejection and a transport that silently
ignores the entry. Every other conjunct rides the request; a partition
that cannot decide one keeps the row, and the compute-side eager filter
still evaluates it.
Sourcepub fn bound_slots(&self) -> usize
pub fn bound_slots(&self) -> usize
Number of ground slots — fallback selectivity when no profile is loaded.
Sourcepub fn slot_of(&self, variable: &Variable) -> Vec<PatternSlot>
pub fn slot_of(&self, variable: &Variable) -> Vec<PatternSlot>
Every pattern slot that binds variable, in subject / predicate /
object order. Empty when the variable is not on this scan.
Sourcepub fn first_slot_of(&self, variable: &Variable) -> Option<PatternSlot>
pub fn first_slot_of(&self, variable: &Variable) -> Option<PatternSlot>
First matching slot, if any (runtime allow-list still uses one slot).
Trait Implementations§
impl StructuralPartialEq for ScanOp
Auto Trait Implementations§
impl Freeze for ScanOp
impl RefUnwindSafe for ScanOp
impl Send for ScanOp
impl Sync for ScanOp
impl Unpin for ScanOp
impl UnsafeUnpin for ScanOp
impl UnwindSafe for ScanOp
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].