Skip to main content

StoreContext

Struct StoreContext 

Source
pub struct StoreContext<'a> { /* private fields */ }
Expand description

The store-backed context for one repo.

Implementations§

Source§

impl<'a> StoreContext<'a>

Source

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).

Source

pub fn repo_id(&self) -> &str

The repository this context is scoped to.

Source

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.

Source

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.

Source

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.

Source

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<'_>

Source§

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 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

Resolve a named root (the from <name> source / directive receiver). Unknown names are Value::Undefined.
Source§

fn get(&self, row: &Value, key: &str) -> Result<Value>

Read a property/relation off a row: a bare identifier (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 more
Source§

fn to_rows(&self, value: &Value) -> Vec<Value>

Coerce a relation/source value into rows.
Source§

fn index_for( &self, collection: &Value, path: &[String], ) -> Option<Rc<dyn RowIndex + '_>>

Optional: a pre-built equality index over 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

Identity of a row for follow cycle detection / dedup and for distinct over unprojected rows.
Source§

fn call_function(&self, name: &str, args: &[Value]) -> Option<Result<Value>>

Optional custom free function. None = not handled: the engine falls back to the builtin table, then errors if that has no such function.
Source§

fn call_method( &self, name: &str, recv: &Value, args: &[Value], ) -> Option<Result<Value>>

Optional custom method (recv.name(args)). None = not handled, as for DataContext::call_function.
Source§

fn regex_dialect(&self) -> RegexDialect

The regex dialect 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.

Auto Trait Implementations§

§

impl<'a> !Freeze for StoreContext<'a>

§

impl<'a> !RefUnwindSafe for StoreContext<'a>

§

impl<'a> !Send for StoreContext<'a>

§

impl<'a> !Sync for StoreContext<'a>

§

impl<'a> !UnwindSafe for StoreContext<'a>

§

impl<'a> Unpin for StoreContext<'a>

§

impl<'a> UnsafeUnpin for StoreContext<'a>

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.