pub struct StoreContext<'a> { /* private fields */ }Expand description
The store-backed context for one repo.
Implementations§
Source§impl<'a> StoreContext<'a>
impl<'a> StoreContext<'a>
Sourcepub fn new(
conn: &'a Connection,
repo_id: &str,
semantic: HashMap<String, SemanticVec>,
) -> Self
pub fn new( conn: &'a Connection, repo_id: &str, semantic: HashMap<String, SemanticVec>, ) -> Self
A context over conn scoped to repo_id, with the query phrases’
vectors for semantic(...) (empty when no provider ran).
Sourcepub fn with_now_ms(self, now_ms: i64) -> Self
pub fn with_now_ms(self, now_ms: i64) -> Self
Resolve the named points of date() (today, now, sow…) at
now_ms instead of the wall clock — the Surface’s clock, which
OMGBASE_SPEC_CLOCK pins (§1.3, 4.8).
Sourcepub fn statements_run(&self) -> usize
pub fn statements_run(&self) -> usize
How many statements this context has run (every SELECT, the root
scans included). A reach-through to the owner’s identity adds none.
Sourcepub fn scans_run(&self) -> usize
pub fn scans_run(&self) -> usize
How many root scans (SELECT … FROM <target> whole) this context has
run — at most one per target per run; none for a block whose probes
the store indexes answered.
Sourcepub fn with_rows_root(self, rows: Vec<Value>) -> Self
pub fn with_rows_root(self, rows: Vec<Value>) -> Self
Serve rows — target-tagged store rows a plan produced — as the
oqx::ROWS_ROOT scan (the residual query’s source). Every other
root and every relation, intrinsic and row function still hits the
store, so the residual sees exactly what a full scan would.
Sourcepub fn with_rows_root_once(self, rows: Vec<Value>) -> Self
pub fn with_rows_root_once(self, rows: Vec<Value>) -> Self
Self::with_rows_root for a residual whose ONLY read of
oqx::ROWS_ROOT is its source scan (the runner checks the AST: the
name appears nowhere else — no ^-reach, no limit/offset, no
nested mention): the rows are moved out on that first read instead
of deep-copied, and a second read — which cannot happen — would see
an empty scan. Same results as Self::with_rows_root, one row copy
and one drop fewer.
Sourcepub fn take_root_failure(&self) -> Option<OqxError>
pub fn take_root_failure(&self) -> Option<OqxError>
The store failure a root scan hit during the run, if any. Every other
read fails through the engine’s channel (get / call_method return
Err); root has none, so it serves an empty scan and leaves the
failure here for the runner to report.
Trait Implementations§
Source§impl DataContext for StoreContext<'_>
impl DataContext for StoreContext<'_>
Source§fn root_object(&self) -> Value
fn root_object(&self) -> Value
The root scope’s row (oqx 0.18): the repository, so ^$it from a
top-level row is the root row and ^$it.docs the docs scan.
Source§fn is_single(&self, value: &Value) -> bool
fn is_single(&self, value: &Value) -> bool
Row position (spec/oqx §3, 0.20): a lazy root scan is a collection; a store row, a lazy owner, the absent-single marker and any other object are one row.
Source§fn materialize(&self, value: Value) -> Value
fn materialize(&self, value: Value) -> Value
A lazy root-scan marker observed as a VALUE is its rows (read once per run); the absent-single marker is absent; everything else is itself. A store row is an object with several columns and the markers have exactly one key, so the common case is one length check.
Source§fn root(&self, name: &str) -> Value
fn root(&self, name: &str) -> Value
from <name> source / directive receiver).
Unknown names are Value::Undefined.Source§fn get(&self, row: &Value, key: &str) -> Result<Value>
fn get(&self, row: &Value, key: &str) -> Result<Value>
field), a
.field segment, or a ^field outer reference all come through here,
each against exactly the row of the scope it names. An absent property
is Ok(Value::Undefined); the engine never looks elsewhere for it. Read moreSource§fn index_for(
&self,
collection: &Value,
path: &[String],
) -> Option<Rc<dyn RowIndex + '_>>
fn index_for( &self, collection: &Value, path: &[String], ) -> Option<Rc<dyn RowIndex + '_>>
collection (a value this
context served as a root or relation) on the property path path
(["customer_id"], ["meta", "id"]; an empty path keys by the row
itself). The engine asks before building its own crate::optimize::HashIndex
for a correlated equality in a nested block (where id == ^customer_id);
None (the default) lets it build one. lookup(value) must return the
ascending positions, into to_rows(collection) in order, of the rows
whose value at path equals value under OQX equality (SEMANTICS §5).
An index may also implement RowIndex::lookup_rows: the engine then
probes it for a statically stable receiver BEFORE reading the
collection, which is never materialized when the index answers.
crate::adapters::indexed::IndexedContext implements the positional
form. The Rc lets a context create indexes on demand.Source§fn identity(&self, row: &Value) -> Value
fn identity(&self, row: &Value) -> Value
$key (SEMANTICS §16, since 0.20):
what follow cycle detection, the per-step union, follow distinct,
distinct over unprojected rows and is compare, and what reading
$key on the row returns. The default is the row’s structural value
(an entry’s is its key either way, before the context is asked); a
store-backed context answers its row id. (The reference spells this
identityOf; the Rust name is kept for source compatibility.)Source§fn call_function(&self, name: &str, args: &[Value]) -> Option<Result<Value>>
fn call_function(&self, name: &str, args: &[Value]) -> Option<Result<Value>>
None = not handled: the engine falls
back to the builtin table, then errors if that has no such function.Source§fn regex_dialect(&self) -> RegexDialect
fn regex_dialect(&self) -> RegexDialect
matches() compiles against. RegexDialect::Oqx
(the default) is the portable baseline the spec tests;
RegexDialect::Native hands the pattern to the regex crate as is —
implementation-defined, not portable. The engine dispatches matches
through DataContext::call_method, so this is read by the context’s
own matches (DefaultContext does, via
crate::semantics::builtin_method_with); plain
crate::semantics::builtin_method is always the baseline.