Skip to main content

ScanOp

Struct ScanOp 

Source
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: EncodedTriplePattern

Encoded 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: u64

Estimated 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: bool

SPARQL 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

Source

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.

Source

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.

Source

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].

Source

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.

Source

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.

Source

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_dead only): 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 set allow_dead only on requests whose rows can never become a start_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.

Source

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.

Source

pub fn slot_variables(&self) -> Vec<Variable>

Slot names in S/P/O/G order, including dead repeats (?x ?p ?x).

Source

pub fn slot_mark(&self, variable: &Variable) -> Option<SlotMark>

Full mark for a slot name. None when variable is not a slot.

Source

pub fn bag_mark(&self, variable: &Variable) -> Option<BagMark>

Bag mark for a slot. None when variable is not a slot on this scan.

Source

pub fn is_live(&self, variable: &Variable) -> bool

Whether variable is a live output column.

Source

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).

Source

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.

Source

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.

Source

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).

Source

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.

Source

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).

Source

pub fn will_collapse(&self) -> bool

Compute-side DISTINCT ON collapse keys (not used by domain / head scans).

Source

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).

Source

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.

Source

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.

Source

pub fn bound_slots(&self) -> usize

Number of ground slots — fallback selectivity when no profile is loaded.

Source

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.

Source

pub fn first_slot_of(&self, variable: &Variable) -> Option<PatternSlot>

First matching slot, if any (runtime allow-list still uses one slot).

Trait Implementations§

Source§

impl Clone for ScanOp

Source§

fn clone(&self) -> ScanOp

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ScanOp

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for ScanOp

Source§

fn eq(&self, other: &ScanOp) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for ScanOp

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> FromRef<T> for T
where T: Clone,

§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> IntoRequest<T> for T

§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
§

impl<L> LayerExt<L> for L

§

fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>
where L: Layer<S>,

Applies the layer to a service and wraps it in [Layered].
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,