logos.std.deem
Module std · package logos-std
Types
structQEnv
struct QEnv
Runtime binding environment for Tpl::render / Query::run: named scalar parameters,
data nodes/sources, and the UDF/UDA registry.
Holds at most 24 value/source bindings; binds past capacity are silently ignored.
Rebinding an existing name overwrites it (last write wins).
Fields
a_argty: [i32; 4]
a_fin: [fn(RtVal) -> RtVal; 4]
a_init: [fn() -> RtVal; 4]
a_n: i64
a_names: [&[u8]; 4]
a_ret: [i32; 4]
a_step: [fn(RtVal, RtVal) -> RtVal; 4]
bvals: [bool; 24]
codes: [u64; 24]
f_args: [i32; 32]
f_arity: [i64; 8]
f_n: i64
f_names: [&[u8]; 8]
f_ptrs: [fn(&[RtVal]) -> RtVal; 8]
f_ret: [i32; 8]
fvals: [f64; 24]
ivals: [i64; 24]
kinds: [i32; 24]
n: i64
names: [&[u8]; 24]
svals: [&[u8]; 24]
words: [i64; 24]
Methods
fn bind_bool(self: &mut QEnv, name: &[u8], v: bool) -> void
Binds name to a bool query/template parameter.
fn bind_f64(self: &mut QEnv, name: &[u8], v: f64) -> void
Binds name to an f64 query/template parameter.
fn bind_i64(self: &mut QEnv, name: &[u8], v: i64) -> void
Binds name to an i64 query/template parameter.
fn bind_node(self: &mut QEnv, name: &[u8], node: WAny) -> void
Binds name to a schema’d Writ object (a WAny ref to a schema-stamped TOM).
The schema code is read off the object; a non-schema value binds with code 0 and is
diagnosed by the strict checker on first use.
fn bind_node_erased(self: &mut QEnv, name: &[u8], node: WAny) -> void
Binds name to an erased (lenient) node: name.field resolves at runtime by name.
A string-keyed Writ map gets by key; a schema-stamped TOM whose schema is in the catalog
gets by the cataloged key; anything else (missing key, unknown schema, non-object) reads
as RtVal::Null, which propagates CEL-style through operators. No catalog entry needed.
fn bind_source(self: &mut QEnv, name: &[u8], arr: WAny) -> void
Binds name to a query source: a Writ array of schema’d rows (from <name> v scans it).
The element schema resolves live at run (off the first element’s stamped code) — an
empty array binds fine and yields no rows.
The caller keeps the backing doc alive across run.
fn bind_source_erased(self: &mut QEnv, name: &[u8], arr: WAny) -> void
Binds name to an erased source: a Writ array of lenient rows (string-keyed maps /
arbitrary Writ values). Scans bind the row var leniently; field types are unknown at
compile, so lenient rows never serve as hash-join keys (such joins take the loop tier).
fn bind_str(self: &mut QEnv, name: &[u8], v: &[u8]) -> void
Binds name to a str parameter; the view must stay valid across render/run.
fn new() -> QEnv
Creates an empty environment with no bindings and no registered UDFs/UDAs.
fn register_agg(self: &mut QEnv, name: &[u8], init: fn() -> RtVal, step: fn(RtVal, RtVal) -> RtVal, fin: fn(RtVal) -> RtVal, arg_ty: &[u8], ret_ty: &[u8]) -> bool
Registers a UDA: init() -> acc, step(acc, arg) -> acc, fin(acc) -> result.
arg_ty/ret_ty are the declared EL types of the aggregate argument and the finalized
result. Builtin aggregate names shadow UDAs. Returns false (nothing registered) on a
bad type name or a full registry (same contract as register_fn).
fn register_fn(self: &mut QEnv, name: &[u8], f: fn(&[RtVal]) -> RtVal, args: &[&[u8]], ret: &[u8]) -> bool
Registers a scalar UDF with its declared signature: args are EL type names
("i64"/"f64"/"bool"/"str", max 4), ret likewise. The checker resolves calls
against builtins first, then this registry; re-registering a name overwrites it.
Returns false (registers nothing) on a bad type name, >4 args, or a full registry.
structQError
struct QError
Runtime error value returned by the fallible Deem APIs (compile/render/run).
Carries the offending name/operator inside the message text; no source offsets.
Fields
msg: String
The owned error message text.
Methods
fn message(self: &QError) -> &[u8]
Returns the error text as a borrowed str view, valid while the QError lives.
structQRows
struct QRows
Materialized query result. Self-contained: string cells are interned into a QRows-owned
arena and outlive both the run and the Query; node cells are handles into the caller’s
data doc, which must stay alive while they are read (the bind_source contract).
Fields
arena: Writ
cells: Vec<RtVal>
kinds: [i32; 8]
ncols: i64
nrows: i64
Methods
fn col_count(self: &QRows) -> i64
Returns the number of result columns.
fn col_ty(self: &QRows, c: i64) -> &[u8]
Returns column c’s checked type name — "i64"/"str"/"bool"/"f64"/"node"/
"dyn" (lenient, runtime-typed) — or "" out of range.
fn get_bool(self: &QRows, r: i64, c: i64) -> bool
Returns cell (r,c) as bool; non-bool and out-of-range cells read as false.
fn get_f64(self: &QRows, r: i64, c: i64) -> f64
Returns cell (r,c) as f64; integer cells coerce, anything else reads as 0.0.
fn get_i64(self: &QRows, r: i64, c: i64) -> i64
Returns cell (r,c) as i64; float/bool cells coerce, anything else reads as 0.
fn get_node(self: &QRows, r: i64, c: i64) -> WAny
Returns cell (r,c) as a row-object handle (identity / find projections) into the
caller’s data doc.
fn get_str(self: &QRows, r: i64, c: i64) -> &[u8]
Returns cell (r,c) as a str view owned by this QRows (interned) — valid while
it lives. Non-string and out-of-range cells read as "".
fn is_null(self: &QRows, r: i64, c: i64) -> bool
Returns whether cell (r,c) is Null. Lenient projections may carry Null (the typed
getters read zero-values for it) — this is the distinguishing probe. Out-of-range
reads also report true.
fn is_some(self: &QRows) -> bool
Returns whether any row matched — the Option-shaped probe for select first / find.
fn row_count(self: &QRows) -> i64
Returns the number of result rows.
structQuery
struct Query
Compiled relational query — compile once with Query::compile, run many with run.
Owns the lowered algebra, a catalog snapshot, and the compiled rel blocks.
Fields
bodies: QBodyTab
cat: SchemaCatalog
doc: Writ
empty: bool
reg: QRelReg
root: i64
sel_mode: i32
Methods
fn compile(text: &[u8], cat: &SchemaCatalog) -> Result
Compiles query text against the catalog into a reusable Query.
Parses, registers/stratifies rel blocks, lowers and simplifies the algebra, and runs
the env-independent checks. Errors are values (Result), never compile diagnostics.
fn incremental(self: &Query, env: &QEnv) -> Result
fn incremental_rec(self: &Query, env: &QEnv) -> Result
fn run(self: &Query, env: &QEnv) -> Result
Executes the query against env and materializes the result as a self-contained QRows.
Runs the full strict check against this env first, then materializes the rels (topo
order, semi-naive where recursive) and executes the entry pipeline. Re-entrant over
different envs (sources, params and the UDF/UDA registry live on the env).
structSchemaCatalog
struct SchemaCatalog
Fields
f_keys: Vec<i64>
f_kinds: Vec<i64>
f_n: i64
f_names: Vec<&[u8]>
f_owner: Vec<i64>
f_targets: Vec<u64>
f_tnames: Vec<&[u8]>
f_tys: Vec<i64>
s_codes: Vec<u64>
s_n: i64
s_names: Vec<&[u8]>
Methods
fn add_edge(self: &mut SchemaCatalog, sname: &[u8], field: &[u8], key: i64, target: &[u8]) -> void
fn add_field(self: &mut SchemaCatalog, sname: &[u8], field: &[u8], key: i64, ty: &[u8]) -> void
fn add_schema(self: &mut SchemaCatalog, name: &[u8], code: u64) -> void
fn field_key(self: &SchemaCatalog, sname: &[u8], field: &[u8]) -> i64
fn field_ty(self: &SchemaCatalog, sname: &[u8], field: &[u8]) -> &[u8]
fn from_static(blob: WritStatic) -> SchemaCatalog
fn merge_static(self: &mut SchemaCatalog, blob: WritStatic) -> void
fn new() -> SchemaCatalog
fn schema_code(self: &SchemaCatalog, name: &[u8]) -> u64
Functions
fnpump_join
fn pump_join(sa: &mut FactStore, sb: &mut FactStore, eng: &mut IncrJoin) -> void
fnpump_rec
fn pump_rec(store: &mut FactStore, eng: &mut IncrRec) -> void