Skip to main content

QueryContext

Struct QueryContext 

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

Per-query policy, identity, and sinks for SPARQL plan + execute.

Clone is cheap (sinks are Arc; the named-graph memo starts empty). Pass &QueryContext; do not put recursion-scoped join keys or the string cache here. The parallel-arm-permit pool is the one shared (not recursion-scoped) budget: it caps how many plan arms of this query run at once, and Clone shares the pool so sub-executions stay inside the same query’s budget. The TermDict is likewise shared across clones of one execute.

Implementations§

Source§

impl QueryContext

Source

pub fn from_snapshot(snapshot: SnapshotId) -> Self

Test / convenience context: query_id = 0, NOW() captured here, default_union = false, sinks off, unrestricted security.

Source

pub fn from_engine( snapshot: SnapshotId, default_union: bool, geo_index_epoch: Option<u64>, ) -> Self

Same as Self::from_snapshot but copies the engine default_union knob and the storage-reported geo_index_epoch.

RDF DefaultGraph is the unnamed graph. SPARQL’s default graph is the window a bare BGP scans: FROM graphs, protocol default-graph-uri, or this fallback (true = all graphs named and unnamed; false = only the RDF unnamed graph).

Source

pub fn query_id(&self) -> u64

Monotonic id for correlating API debug lines with compute log/trace.

Source

pub fn snapshot(&self) -> SnapshotId

MVCC snapshot this query reads as of.

Source

pub fn now(&self) -> SystemTime

Instant captured at context construction (SPARQL NOW() must be stable).

Source

pub fn default_union(&self) -> bool

Engine/session fallback for the SPARQL default graph when no FROM list.

Source

pub fn seat_by_total_cost(&self) -> bool

Inner-join arm seating comparator (copied from the engine; false keeps the legacy driver_cost decision).

Source

pub fn force_semi(&self) -> bool

Benchmark switch: force Semi past a PerPage cost verdict.

Source

pub fn eager_scan_filter(&self) -> bool

Whether the planner stamps slot comparisons and the executor applies the eager scan filter. false is the pre-feature path: nothing is stamped (no wire comparison, no memo/Slice/omitted-slot effect) and every conjunct stays in the plan.

Source

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

Geo-index rebuild epoch reported by the O partition (None = never stamped — treated as trusted by the geo planner rewrite).

Source

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

Temporal-index rebuild epoch reported by the O partition (None = never stamped — UNTRUSTED for the temporal planner rewrite: temporal literals predate the plugin, so a missing epoch means the index may not cover the store yet; the compute auto-rebuild stamps it at startup before queries are served).

Source

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

Text-index rebuild epoch reported by the O partition (None = UNTRUSTED — the text plugin rewrites stay off; text:query fails the query and prefix/suffix falls back to the exact residual).

Source

pub fn text_index_fingerprint(&self) -> &str

Config fingerprint of the partition’s text index (empty when none). A mismatch with the plugin config means the index must be rebuilt before rewrites resume.

Source

pub fn temporal_histogram(&self) -> Option<&Arc<TickHistogram>>

Rolled-up temporal tick histogram (advisory estimates; None when the rolled-up profile carries none).

Source

pub fn geo_cell_histogram(&self) -> Option<&Arc<GeoCellHistogram>>

Rolled-up geo cell-count histogram (advisory estimates; None when the rolled-up profile carries none).

Source

pub fn text_seed_sketch(&self) -> Option<&Arc<TextSeedSketch>>

Rolled-up text seed-population sketch (advisory candidate-drain estimates; None when the rolled-up profile carries none).

Source

pub fn dataset(&self) -> &QueryDataset

Resolved SPARQL dataset (FROM / protocol / engine fallback).

Source

pub fn protocol_default_graphs(&self) -> &[String]

SPARQL Protocol default-graph-uri values (may be empty).

Source

pub fn protocol_named_graphs(&self) -> &[String]

SPARQL Protocol named-graph-uri values (may be empty).

Source

pub fn base_iri(&self) -> Option<&str>

Query base IRI for resolving relative IRIs in the query text.

None leaves the engine’s current behavior: relative IRI references are a parse error (spargebra stores absolute IRIs only).

Source

pub fn security(&self) -> &SecurityContext

Stub security policy.

Source

pub fn trace(&self) -> &TraceSink

Execution trace sink.

Source

pub fn log_sink(&self) -> &LogSink

Operational log sink.

Source

pub fn perf(&self) -> &PhaseTimers

Per-query scan / resolve wall-time totals (shared across clones).

Source

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

Query-local intern table (shared across clones of this execute).

Source

pub fn memory_budget_bytes(&self) -> u64

Per-query byte budget for join chunk sizing (Phase 2) and spill (Phase 3).

Concurrent queries each get their own budget; they do not subtract from a process-wide pool yet (follow-on work).

Source

pub fn join_chunk_rows(&self, width: usize, cap: usize) -> usize

Max output rows for one eager join chunk given column width.

budget / (width * 4) clamped to [1, cap]. cap is typically DEFAULT_JOIN_CHUNK_CAP / SCAN_BATCH.

Source

pub fn with_memory_budget_bytes(self, bytes: u64) -> Self

Override the per-query RAM budget (tests use small values).

Source

pub fn spill_dir(&self) -> Option<&PathBuf>

Directory for per-query spill files (ORDER BY external sort, parked pages).

Source

pub fn with_spill_dir(self, dir: PathBuf) -> Self

Set the directory this query’s spill files are created under (ORDER BY external sort runs, parked pages, Grace join partitions, DISTINCT seen-set partitions).

Engines copy the operator-configured root here; without it files go to std::env::temp_dir, which is RAM-backed (tmpfs) on many Linux systems and defeats spilling. Must be set before the first spill — the workdir is cached once created.

Source

pub fn log(&self, level: LogLevel, message: &str)

Write an operational log line when the sink enables level. Every line carries the elapsed wall time since context build (at=+…ms) so the timeline between lines reads directly off the log.

The sink check happens before any formatting: callers with measurement work (spans, readout walks) should consult Self::log_sink’s enabled_at themselves so the disabled path does no work at all.

Source

pub fn deadline(&self) -> Option<Instant>

Optional wall-clock deadline (honored before hexastore RPCs and materialize).

Source

pub fn cancel(&self) -> Option<&Arc<AtomicBool>>

Optional cancellation flag (honored before hexastore RPCs, materialize, and return).

Source

pub fn check_abort(&self) -> Result<(), ComputeError>

Abort if the cancel token is set or the deadline has passed.

Called before hexastore RPCs (crate::query::QueryEngine::scan_page, property-path hop pages) and after execute before registry materialize. Compute-side joins / FILTERs are not checked.

Source

pub fn check_cancelled(&self) -> Result<(), ComputeError>

Abort if the cancel token is set. Deadline is ignored.

Used after materialize, when the query is finished and we only decide whether to hand the result back.

Source

pub fn with_query_id(self, query_id: u64) -> Self

Set the correlating query id (API / CLI).

Source

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

Override SPARQL default-graph fallback (copied from the engine by default).

Source

pub fn with_seat_by_total_cost(self, seat_by_total_cost: bool) -> Self

Seat inner joins by the total seating cost (copied from the engine).

Source

pub fn with_force_semi(self, force_semi: bool) -> Self

Benchmark switch: force Semi past a PerPage cost verdict. The semantic semi gates (payload, multiplicity, keys, specialized scan) still refuse; only the price loses its veto.

Source

pub fn with_eager_scan_filter(self, eager_scan_filter: bool) -> Self

Enable or disable slot comparison stamping and the eager scan filter. false is the pre-feature path: no comparison is stamped, so none reaches the wire and every conjunct stays in the plan.

Source

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

Set the geo-index rebuild epoch (copied from the engine by default).

Source

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

Set the temporal-index rebuild epoch (copied from the engine by default).

Source

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

Set the text-index rebuild epoch and fingerprint (copied from the engine by default; None epoch = untrusted).

Source

pub fn with_temporal_histogram( self, temporal_histogram: Option<Arc<TickHistogram>>, ) -> Self

Set the rolled-up temporal tick histogram snapshot.

Source

pub fn with_geo_cell_histogram( self, geo_cell_histogram: Option<Arc<GeoCellHistogram>>, ) -> Self

Set the rolled-up geo cell-count histogram snapshot.

Source

pub fn with_text_seed_sketch( self, text_seed_sketch: Option<Arc<TextSeedSketch>>, ) -> Self

Set the rolled-up text seed-population sketch snapshot.

Source

pub fn with_protocol_dataset( self, default_graphs: Vec<String>, named_graphs: Vec<String>, ) -> Self

SPARQL Protocol dataset IRIs (override query-text FROM when non-empty).

Source

pub fn with_base_iri(self, base_iri: Option<String>) -> Self

Set the base IRI used when parsing the query text.

Relative IRIs in the query (FROM <data.ttl>, GRAPH <g.ttl>, IRI template terms) resolve against this. Callers that already know their queries are absolute-IRI-only (HTTP API, CLI) leave it unset.

Source

pub fn with_log(self, log: LogSink) -> Self

Replace the operational log sink.

Source

pub fn with_trace(self, trace: TraceSink) -> Self

Replace the execution trace sink.

Source

pub fn with_deadline(self, deadline: Option<Instant>) -> Self

Wall-clock deadline checked before hexastore RPCs and materialize.

Source

pub fn with_cancel(self, cancel: Option<Arc<AtomicBool>>) -> Self

Cooperative cancellation checked before hexastore RPCs, materialize, and return.

Source

pub fn with_security(self, security: SecurityContext) -> Self

Replace the security stub (still unused).

Trait Implementations§

Source§

impl Clone for QueryContext

Source§

fn clone(&self) -> QueryContext

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 QueryContext

Source§

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

Formats the value using the given formatter. Read more

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,