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
impl QueryContext
Sourcepub fn from_snapshot(snapshot: SnapshotId) -> Self
pub fn from_snapshot(snapshot: SnapshotId) -> Self
Test / convenience context: query_id = 0, NOW() captured here,
default_union = false, sinks off, unrestricted security.
Sourcepub fn from_engine(
snapshot: SnapshotId,
default_union: bool,
geo_index_epoch: Option<u64>,
) -> Self
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).
Sourcepub fn query_id(&self) -> u64
pub fn query_id(&self) -> u64
Monotonic id for correlating API debug lines with compute log/trace.
Sourcepub fn snapshot(&self) -> SnapshotId
pub fn snapshot(&self) -> SnapshotId
MVCC snapshot this query reads as of.
Sourcepub fn now(&self) -> SystemTime
pub fn now(&self) -> SystemTime
Instant captured at context construction (SPARQL NOW() must be stable).
Sourcepub fn default_union(&self) -> bool
pub fn default_union(&self) -> bool
Engine/session fallback for the SPARQL default graph when no FROM list.
Sourcepub fn seat_by_total_cost(&self) -> bool
pub fn seat_by_total_cost(&self) -> bool
Inner-join arm seating comparator (copied from the engine; false
keeps the legacy driver_cost decision).
Sourcepub fn force_semi(&self) -> bool
pub fn force_semi(&self) -> bool
Benchmark switch: force Semi past a PerPage cost verdict.
Sourcepub fn eager_scan_filter(&self) -> bool
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.
Sourcepub fn geo_index_epoch(&self) -> Option<u64>
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).
Sourcepub fn temporal_index_epoch(&self) -> Option<u64>
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).
Sourcepub fn text_index_epoch(&self) -> Option<u64>
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).
Sourcepub fn text_index_fingerprint(&self) -> &str
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.
Sourcepub fn temporal_histogram(&self) -> Option<&Arc<TickHistogram>>
pub fn temporal_histogram(&self) -> Option<&Arc<TickHistogram>>
Rolled-up temporal tick histogram (advisory estimates; None when
the rolled-up profile carries none).
Sourcepub fn geo_cell_histogram(&self) -> Option<&Arc<GeoCellHistogram>>
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).
Sourcepub fn text_seed_sketch(&self) -> Option<&Arc<TextSeedSketch>>
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).
Sourcepub fn dataset(&self) -> &QueryDataset
pub fn dataset(&self) -> &QueryDataset
Resolved SPARQL dataset (FROM / protocol / engine fallback).
Sourcepub fn protocol_default_graphs(&self) -> &[String]
pub fn protocol_default_graphs(&self) -> &[String]
SPARQL Protocol default-graph-uri values (may be empty).
Sourcepub fn protocol_named_graphs(&self) -> &[String]
pub fn protocol_named_graphs(&self) -> &[String]
SPARQL Protocol named-graph-uri values (may be empty).
Sourcepub fn base_iri(&self) -> Option<&str>
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).
Sourcepub fn security(&self) -> &SecurityContext
pub fn security(&self) -> &SecurityContext
Stub security policy.
Sourcepub fn perf(&self) -> &PhaseTimers
pub fn perf(&self) -> &PhaseTimers
Per-query scan / resolve wall-time totals (shared across clones).
Sourcepub fn term_dict(&self) -> Arc<TermDict>
pub fn term_dict(&self) -> Arc<TermDict>
Query-local intern table (shared across clones of this execute).
Sourcepub fn memory_budget_bytes(&self) -> u64
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).
Sourcepub fn join_chunk_rows(&self, width: usize, cap: usize) -> usize
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.
Sourcepub fn with_memory_budget_bytes(self, bytes: u64) -> Self
pub fn with_memory_budget_bytes(self, bytes: u64) -> Self
Override the per-query RAM budget (tests use small values).
Sourcepub fn spill_dir(&self) -> Option<&PathBuf>
pub fn spill_dir(&self) -> Option<&PathBuf>
Directory for per-query spill files (ORDER BY external sort, parked pages).
Sourcepub fn with_spill_dir(self, dir: PathBuf) -> Self
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.
Sourcepub fn log(&self, level: LogLevel, message: &str)
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.
Sourcepub fn deadline(&self) -> Option<Instant>
pub fn deadline(&self) -> Option<Instant>
Optional wall-clock deadline (honored before hexastore RPCs and materialize).
Sourcepub fn cancel(&self) -> Option<&Arc<AtomicBool>>
pub fn cancel(&self) -> Option<&Arc<AtomicBool>>
Optional cancellation flag (honored before hexastore RPCs, materialize, and return).
Sourcepub fn check_abort(&self) -> Result<(), ComputeError>
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.
Sourcepub fn check_cancelled(&self) -> Result<(), ComputeError>
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.
Sourcepub fn with_query_id(self, query_id: u64) -> Self
pub fn with_query_id(self, query_id: u64) -> Self
Set the correlating query id (API / CLI).
Sourcepub fn with_default_union(self, default_union: bool) -> Self
pub fn with_default_union(self, default_union: bool) -> Self
Override SPARQL default-graph fallback (copied from the engine by default).
Sourcepub fn with_seat_by_total_cost(self, seat_by_total_cost: bool) -> Self
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).
Sourcepub fn with_force_semi(self, force_semi: bool) -> Self
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.
Sourcepub fn with_eager_scan_filter(self, eager_scan_filter: bool) -> Self
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.
Sourcepub fn with_geo_index_epoch(self, geo_index_epoch: Option<u64>) -> Self
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).
Sourcepub fn with_temporal_index_epoch(
self,
temporal_index_epoch: Option<u64>,
) -> Self
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).
Sourcepub fn with_text_index_state(
self,
text_index_epoch: Option<u64>,
text_index_fingerprint: impl Into<Arc<str>>,
) -> Self
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).
Sourcepub fn with_temporal_histogram(
self,
temporal_histogram: Option<Arc<TickHistogram>>,
) -> Self
pub fn with_temporal_histogram( self, temporal_histogram: Option<Arc<TickHistogram>>, ) -> Self
Set the rolled-up temporal tick histogram snapshot.
Sourcepub fn with_geo_cell_histogram(
self,
geo_cell_histogram: Option<Arc<GeoCellHistogram>>,
) -> Self
pub fn with_geo_cell_histogram( self, geo_cell_histogram: Option<Arc<GeoCellHistogram>>, ) -> Self
Set the rolled-up geo cell-count histogram snapshot.
Sourcepub fn with_text_seed_sketch(
self,
text_seed_sketch: Option<Arc<TextSeedSketch>>,
) -> Self
pub fn with_text_seed_sketch( self, text_seed_sketch: Option<Arc<TextSeedSketch>>, ) -> Self
Set the rolled-up text seed-population sketch snapshot.
Sourcepub fn with_protocol_dataset(
self,
default_graphs: Vec<String>,
named_graphs: Vec<String>,
) -> Self
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).
Sourcepub fn with_base_iri(self, base_iri: Option<String>) -> Self
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.
Sourcepub fn with_trace(self, trace: TraceSink) -> Self
pub fn with_trace(self, trace: TraceSink) -> Self
Replace the execution trace sink.
Sourcepub fn with_deadline(self, deadline: Option<Instant>) -> Self
pub fn with_deadline(self, deadline: Option<Instant>) -> Self
Wall-clock deadline checked before hexastore RPCs and materialize.
Sourcepub fn with_cancel(self, cancel: Option<Arc<AtomicBool>>) -> Self
pub fn with_cancel(self, cancel: Option<Arc<AtomicBool>>) -> Self
Cooperative cancellation checked before hexastore RPCs, materialize, and return.
Sourcepub fn with_security(self, security: SecurityContext) -> Self
pub fn with_security(self, security: SecurityContext) -> Self
Replace the security stub (still unused).
Trait Implementations§
Source§impl Clone for QueryContext
impl Clone for QueryContext
Source§fn clone(&self) -> QueryContext
fn clone(&self) -> QueryContext
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl !Freeze for QueryContext
impl RefUnwindSafe for QueryContext
impl Send for QueryContext
impl Sync for QueryContext
impl Unpin for QueryContext
impl UnsafeUnpin for QueryContext
impl UnwindSafe for QueryContext
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].