Skip to main content

QueryEngine

Struct QueryEngine 

Source
pub struct QueryEngine<H, R> { /* private fields */ }
Expand description

SPARQL coordinator over the hexastore and registry endpoints.

Implementations§

Source§

impl<H, R> QueryEngine<H, R>

Source

pub fn new( hexastore: H, registry: R, router: Router, retry: RetryPolicy, ) -> Self

Build over injected clients (mocks in unit tests; tonic in integration).

Source

pub fn default_union(&self) -> bool

SPARQL default-graph fallback copied onto QueryContext.

Source

pub fn set_default_union(&mut self, default_union: bool)

Set the SPARQL default-graph fallback (false = RDF unnamed graph only).

Source

pub fn set_seat_by_total_cost(&mut self, seat_by_total_cost: bool)

Seat inner joins by the total seating cost (false = legacy driver_cost comparator; the shadow log is unaffected).

Source

pub fn seat_by_total_cost(&self) -> bool

Inner-join seating comparator currently configured.

Source

pub fn set_force_semi(&mut self, force_semi: bool)

Benchmark switch: force Semi past a PerPage cost verdict.

Source

pub fn eager_scan_filter(&self) -> bool

Whether scans stamp and apply slot comparisons.

Source

pub fn set_eager_scan_filter(&mut self, enabled: bool)

Test/benchmark switch for slot comparison pushdown and the eager scan filter. Production leaves it on; the equivalence battery turns it off to prove identical answers, and a benchmark uses it for the on/off delta. Off is the pre-feature path: nothing is stamped, so no comparison reaches the wire and every conjunct stays in the plan.

Source

pub fn with_default_union(self, default_union: bool) -> Self

Builder: SPARQL default-graph fallback.

Source

pub fn geo_index_epoch(&self) -> Option<u64>

Geo-index rebuild epoch copied onto QueryContext.

Source

pub fn set_geo_index_epoch(&mut self, geo_index_epoch: Option<u64>)

Set the geo-index rebuild epoch (None = trusted).

Source

pub fn with_geo_index_epoch(self, geo_index_epoch: Option<u64>) -> Self

Builder: geo-index rebuild epoch (None = trusted).

Source

pub fn temporal_index_epoch(&self) -> Option<u64>

Temporal-index rebuild epoch copied onto QueryContext.

Source

pub fn set_temporal_index_epoch(&mut self, temporal_index_epoch: Option<u64>)

Set the temporal-index rebuild epoch (None = untrusted).

Source

pub fn with_temporal_index_epoch( self, temporal_index_epoch: Option<u64>, ) -> Self

Builder: temporal-index rebuild epoch (None = untrusted).

Source

pub fn text_index_epoch(&self) -> Option<u64>

Text-index rebuild epoch copied onto QueryContext (None = untrusted).

Source

pub fn set_text_index_state( &mut self, epoch: Option<u64>, fingerprint: impl Into<Arc<str>>, )

Set the text-index rebuild epoch and fingerprint.

Source

pub fn with_text_index_state( self, epoch: Option<u64>, fingerprint: impl Into<Arc<str>>, ) -> Self

Builder: text-index rebuild epoch + fingerprint (None = untrusted).

Source

pub fn spill_root(&self) -> Option<&Path>

Spill root copied onto QueryContext (None = std::env::temp_dir).

Source

pub fn set_spill_root(&mut self, spill_root: Option<PathBuf>)

Set the spill root copied onto each QueryContext.

Source

pub fn with_spill_root(self, spill_root: Option<PathBuf>) -> Self

Builder: spill root copied onto each QueryContext.

Source

pub fn context(&self, snapshot: SnapshotId) -> QueryContext

Per-query context with this engine’s default_union, spill root, index epochs, and snapshot.

Source

pub fn path_pair_budget(&self) -> u64

Distinct-pair circuit breaker for bound / one-end property paths.

Source

pub fn set_path_pair_budget(&mut self, budget: u64)

Set the distinct-pair circuit breaker (default PATH_PAIR_BUDGET).

Source

pub fn open_star_pair_budget(&self) -> u64

Distinct-pair circuit breaker for * / + with no LIMIT.

Source

pub fn set_open_star_pair_budget(&mut self, budget: u64)

Set the open-* / + pair budget (default OPEN_STAR_PAIR_BUDGET).

Source

pub fn describe_mode(&self) -> DescribeMode

DESCRIBE algorithm used by Self::query.

Source

pub fn set_describe_mode(&mut self, mode: DescribeMode)

Set the DESCRIBE algorithm (star default).

Source

pub fn with_describe_mode(self, mode: DescribeMode) -> Self

Builder: set the DESCRIBE algorithm.

Source

pub fn router(&self) -> &Router

Router used to pick an axis (and, later, a node) per scan.

Source

pub fn hexastore(&self) -> &H

Hexastore clients.

Source

pub fn registry(&self) -> &R

Registry clients.

Source

pub fn set_profile(&self, profile: StatsProfile)

Replace the local sketch cache (tests / in-process push). The whole [EngineProfile] is swapped as one new inner Arc — snapshots taken by outstanding queries keep planning against the generation they saw.

Source

pub fn profile(&self) -> StatsProfile

Snapshot of the local sketch cache (an owned deep copy — admin and EXPLAIN paths, not the per-query hot path; see Self::engine_profile).

Source§

impl QueryEngine<GrpcHexastoreClients, GrpcRegistryClients>

Source

pub async fn connect( config: &ClusterConfig, retry: RetryPolicy, ) -> Result<Self, ComputeError>

Connect tonic clients for every address in config.

Source§

impl<H: HexastoreStats, R> QueryEngine<H, R>

Source

pub async fn refresh_stats(&self) -> Result<StatsProfile, ComputeError>

Pull shard profiles from S/P/O and roll up into the local cache.

Because writes fan out to all three axes, roll-up prefers the O profile rather than summing replicas. Named-graph count is taken from S. The result is re-capped so a future with several same-axis shard profiles (whose merge could union two capped HLL sets) still keeps the planner cache bounded.

Source§

impl<H: HexastoreScan + HexastoreCatalog + HexastoreGeo, R: StringResolve + BlobStoreClient> QueryEngine<H, R>

Source

pub async fn query( &self, sparql: &str, ctx: &QueryContext, ) -> Result<QueryResults, ComputeError>

Parse, plan, execute, and materialize a SPARQL SELECT, ASK, CONSTRUCT, or DESCRIBE.

The execution dataset is QueryDataset::resolve of ctx protocol graph IRIs, the query’s FROM / FROM NAMED clause, and QueryContext::default_union. A dataset already stored on ctx is replaced.

Source

pub async fn query_output( &self, sparql: &str, ctx: &QueryContext, ) -> Result<QueryOutput, ComputeError>

Parse, plan, execute, and late-materialize SPARQL results.

SELECT returns encoded projected columns plus the interned string map from a registry resolve — not decoded oxrdf [Term]s. ASK / CONSTRUCT / DESCRIBE return QueryOutput::Ready.

The execution dataset is QueryDataset::resolve of ctx protocol graph IRIs, the query’s FROM / FROM NAMED clause, and QueryContext::default_union. A dataset already stored on ctx is replaced.

Source

pub async fn quad_count( &self, snapshot: SnapshotId, ) -> Result<u64, ComputeError>

Count quads visible as of snapshot (unbound S/SPOG prefix count).

Counts the default graph on the S axis. The partition walks SPOG locally and returns a single integer; matching quads are not sent to compute.

Source

pub async fn count_encoded_pattern( &self, pattern: &EncodedTriplePattern, snapshot: SnapshotId, axis: PartitionAxis, permutation: Option<IndexPermutation>, ) -> Result<u64, ComputeError>

Count quads matching pattern on axis without returning rows.

Source

pub async fn execute( &self, plan: &LogicalPlan, ctx: &QueryContext, ) -> Result<EncodedSolutions, ComputeError>

Run a planned query, stopping before string materialization.

The plan and ctx must agree on whether the eager scan filter runs: planning deletes exact FILTER conjuncts into the scans’ comparisons when it runs, so a plan built that way cannot be executed with the filter switched off. Plan under the executing context (LogicalPlan::parse_with_context) when the filter setting differs from the planner default.

Source

pub async fn resolve_projection( &self, projection: &[Variable], solutions: &EncodedSolutions, ctx: &QueryContext, cache: &QueryCaches, ) -> Result<ProjectedSolutions, ComputeError>

Resolve unique projected hashes, then drop unprojected join-key columns.

This is the registry RPC half of late materialization. HTTP serializes from the returned map; Self::materialize still decodes into owned [Term]s for query() / CLI / compliance.

Source

pub async fn materialize( &self, projection: &[Variable], solutions: &EncodedSolutions, ctx: &QueryContext, cache: &QueryCaches, ) -> Result<QueryResults, ComputeError>

Resolve the hashes of projected columns and rebuild oxrdf terms.

Only projected variables reach the registry: intermediate join columns stay encoded for the whole query.

Trait Implementations§

Source§

impl<H: Clone, R: Clone> Clone for QueryEngine<H, R>

Source§

fn clone(&self) -> QueryEngine<H, R>

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<H: Debug, R: Debug> Debug for QueryEngine<H, R>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<H, R> Freeze for QueryEngine<H, R>
where H: Freeze, R: Freeze,

§

impl<H, R> RefUnwindSafe for QueryEngine<H, R>

§

impl<H, R> Send for QueryEngine<H, R>
where H: Send, R: Send,

§

impl<H, R> Sync for QueryEngine<H, R>
where H: Sync, R: Sync,

§

impl<H, R> Unpin for QueryEngine<H, R>
where H: Unpin, R: Unpin,

§

impl<H, R> UnsafeUnpin for QueryEngine<H, R>
where H: UnsafeUnpin, R: UnsafeUnpin,

§

impl<H, R> UnwindSafe for QueryEngine<H, R>
where H: UnwindSafe, R: UnwindSafe,

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,