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 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 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); everything else is itself. A store row is an object with several columns and the marker has 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
follow cycle detection / dedup and for
distinct over unprojected rows.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.