Skip to main content

EncodedSolutions

Struct EncodedSolutions 

Source
pub struct EncodedSolutions { /* private fields */ }
Expand description

Variable-keyed columnar solutions of interned TermIds.

Rows may live in batch and/or in TermId page files (Self::is_parked). Random-access methods hydrate files into RAM once; join chunking streams pages without loading the full table.

Implementations§

Source§

impl EncodedSolutions

Source

pub fn dict(&self) -> Arc<TermDict>

Shared intern table for this solution table.

Source

pub fn from_scan( dict: Arc<TermDict>, scan: &ScanOp, rows: Vec<EncodedQuad>, ) -> Result<Self, ComputeError>

Project scan rows onto live and counted variables that the scan binds.

Slot Options stay set even when a name is dead. Repeated names (?x :p ?x) still build equality pairs on the quad and drop rows whose slots disagree. Live names and counted names (COUNT(?v) / plain COUNT(*) multiplicity) are included in the TermId schema; other dead names are omitted.

Merge-default scans (ScanOp::merge_default_graph) already unique S/P/O on storage and rewrite G to EncodedTerm::DefaultGraph. This projection still ignores G when scan.graph is unset — users never see that slot.

Source

pub fn from_domain_scan_hits( dict: Arc<TermDict>, scan: &ScanOp, kind: DomainScanKind, hits: &[DomainScanHit], ) -> Result<Self, ComputeError>

Build from (constraint, head) domain-scan hits.

Columns follow S/P/O/G order: the constraint slot sorts before the head slot except on ObjectPreds (head ?p, constraint ?o), and a live grounded ?g projects last as the bound graph constant. Const constraints produce no constraint column; grounded-kept constraints repeat the constant on every row.

Source

pub fn from_domain_count_hits( dict: Arc<TermDict>, scan: &ScanOp, kind: DomainScanKind, hits: &[DomainScanCountHit], ) -> Result<Self, ComputeError>

Build from domain count hits by run-length expansion: count copies of each pair’s row, in key order. Page columns are [domain_rpc_count_page_columns] — counted dead slots get a bound placeholder so Group COUNT(?v) matches multiplicity without broadcasting subject terms on the wire.

Source

pub fn from_head_terms( dict: Arc<TermDict>, scan: &ScanOp, kind: HeadScanKind, terms: &[EncodedTerm], ) -> Result<Self, ComputeError>

Build from bare axis-head terms. Live columns: the head, plus — on the TSG classes scan — the implicit rdf:type predicate when a grounded-kept ?p is projected, and a grounded ?g as the bound graph constant. The bare gates keep every other slot dead.

Source

pub fn from_bound_rows( dict: Arc<TermDict>, variables: Vec<Variable>, rows: Vec<Vec<EncodedTerm>>, ) -> Result<Self, ComputeError>

Build from fully bound rows.

Source

pub fn empty(dict: Arc<TermDict>, variables: Vec<Variable>) -> Self

Empty solution set over variables.

Source

pub fn variables(&self) -> &[Variable]

Variables bound by these solutions, in column order.

Source

pub fn optional_rows( &self, ) -> Result<Vec<Vec<Option<EncodedTerm>>>, ComputeError>

Rows with unbound cells as None (for OPTIONAL / FILTER).

Source

pub fn fill_optional_row( &self, row: usize, out: &mut [Option<EncodedTerm>], ) -> Result<(), ComputeError>

Fill out with encoded terms for row (one dict lock). out.len() is width.

Source

pub fn from_optional_rows( dict: Arc<TermDict>, variables: Vec<Variable>, rows: Vec<Vec<Option<EncodedTerm>>>, ) -> Result<Self, ComputeError>

Build from optional row cells (None = unbound).

Source

pub fn len(&self) -> usize

Number of solutions.

Source

pub fn is_empty(&self) -> bool

Whether there are no solutions.

Source

pub fn get( &self, row: usize, variable: &Variable, ) -> Result<Option<EncodedTerm>, ComputeError>

Value of variable in row, if this set binds it.

Ok(None) is unbound or a name this table does not carry. Err is a hydrate failure on a parked table — not an unbound cell.

Source

pub fn is_bound( &self, row: usize, variable: &Variable, ) -> Result<bool, ComputeError>

Whether variable is bound in row.

Source

pub fn column( &self, variable: &Variable, ) -> Result<Option<&TermColumn>, ComputeError>

Column for variable, if this set binds it.

Missing schema names return Ok(None) without hydrating. Parked-file I/O errors return Err.

Source

pub fn left_join( &self, right: &Self, hash_keys: &[Variable], early_filter: Option<&Expression>, env: &ExprEvalEnv, ) -> Result<Self, ComputeError>

Left outer join for SPARQL OPTIONAL (Phase 9c).

early_filter is folded into the Diff-once probe. Immediate gather fails closed on NeedsResolve (see left_hash_join_columnar); callers that need ground Diff-once for NeedsResolve must use Self::left_join_indices.

Source

pub fn left_join_indices( &self, right: &Self, hash_keys: &[Variable], early_filter: Option<&Expression>, env: &ExprEvalEnv, ) -> Result<LeftJoinIndices, ComputeError>

Diff-once index lists for OPTIONAL (before gather), with early probe marks.

Source

pub fn gather_left_join( &self, right: &Self, indices: &LeftJoinIndices, ) -> Result<Self, ComputeError>

Gather LeftJoin output from (possibly residual-filtered) index lists.

Source

pub fn hash_join( &self, right: &Self, hash_keys: &[Variable], ) -> Result<Self, ComputeError>

Inner hash join with right on always-bound hash_keys (columnar kernel).

An empty hash_keys list is a cartesian product (then soft reconcile for shared maybe-unbound columns). The smaller side is the build side.

Source

pub fn hash_join_capped( &self, right: &Self, hash_keys: &[Variable], max_out: usize, cursor: JoinCursor, build: &mut Option<JoinBuild>, ) -> Result<(Self, Option<JoinCursor>), ComputeError>

Probe self (left) against right for at most max_out output rows, resuming at cursor. Builds the right HT into build when that slot is empty; later pulls reuse it. None next-cursor means this left×right pair is done.

Source

pub fn shuffle_join( &self, right: &Self, hash_keys: &[Variable], ) -> Result<Self, ComputeError>

Shuffle join: hash-partition both sides then join per bucket (Phase 9b).

Source

pub fn union(self, right: Self) -> Result<Self, ComputeError>

SPARQL UNION: multiset concat after aligning to the name-union schema.

Variables present on only one side are unbound (None) on rows from the other side. Column order is left-first, then right-only names.

A parked operand keeps its page files when the two schemas already match; when they do not, both sides hydrate and the result is an in-RAM table. Row order across a parked pair is unspecified — the row multiset is exactly left ++ right, but a non-empty left-hand RAM tail is emitted after the right-hand page files, because the tail is structurally the table’s last segment.

Source

pub fn concat(self, other: Self) -> Result<Self, ComputeError>

Concatenate two solution sets that share a schema (batch refill).

The schemas must match exactly — the same variables in the same column order. A caller whose arms may differ wants Self::union, which widens the schema and pads missing columns as unbound; reaching this with mismatched schemas is a caller bug, so it is reported rather than repaired.

“Share a schema” is about the column layout, not residency: either side may be parked, and a same-schema parked pair merges through the parked road (which may hydrate a side). Row order across a parked pair is unspecified — see Self::union.

Source

pub fn slice_rows( &self, start: usize, length: Option<usize>, ) -> Result<Self, ComputeError>

SPARQL Slice: drop start rows, then keep length (None = the rest).

Exact-range random access: returns exactly min(length, len - start) rows — never fewer while the range is non-empty. On a parked table this hydrates: the first call reads every spill page into RAM (cached on the table), so later calls are free but the memory is already spent.

Misuse hazard: do not call this per-pull to page through a parked table (an OpenNode-style cursor). One call materializes the whole input just to serve one page — the full-hydration bug class the spill layer exists to prevent. Bounded paging belongs to [crate::spill::take_slice], which returns at most length rows without hydrating; that function has the opposite contract, so read its doc before swapping the two.

Source

pub fn apply_distinct( &self, state: &mut DistinctState, keys: &[Variable], ) -> Result<Self, ComputeError>

SPARQL DISTINCT: keep first-seen rows on keys (SELECT projection).

Missing keys are treated as unbound in every row. Extra non-key columns are carried from the kept input rows.

Source

pub fn gather(&self, indices: &[usize]) -> Result<Self, ComputeError>

Gather rows by index (used by FILTER).

Source

pub fn any_bound(&self, variable: &Variable) -> Result<bool, ComputeError>

Whether any row binds variable (false when this table does not carry it). One short-circuiting id scan — the join filter emptiness gates ask exactly this, without Self::distinct_values’s dedupe + promotion pipeline.

Bound is the id-level definition: a cell is bound iff its id is non-zero, and every column id was interned in this table’s own dict by construction, so id != 0 is exactly the boundness distinct_values reported — no dict lookup is needed to confirm it.

Source

pub fn distinct_values( &self, variable: &Variable, ) -> Result<Vec<EncodedTerm>, ComputeError>

Distinct bound values of variable across all rows.

Source

pub fn distinct_count(&self, variable: &Variable) -> Result<usize, ComputeError>

Number of distinct bound values of variable (unbound cells skipped).

Same id-scan as Self::distinct_values without resolving terms.

Trait Implementations§

Source§

impl Clone for EncodedSolutions

Source§

fn clone(&self) -> Self

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 EncodedSolutions

Source§

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

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

impl PartialEq for EncodedSolutions

Source§

fn eq(&self, other: &Self) -> 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.

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,