Skip to main content

Module sparql_ast

Module sparql_ast 

Source
Expand description

SPARQL AST - Index-Based Zero-Allocation Query Representation

Uses u16 indices into flat arrays to avoid Box allocation and recursive type errors. Fully compliant with AGENTS.md zero-allocation constraints.

Structs§

AskQuery
ASK query
BindingRow
Binding row - stack-allocated row for variable bindings
ConstructQuery
CONSTRUCT query
DescribeQuery
DESCRIBE query
LiteralTable
Query-scoped table of literal text + optional language tag / datatype IRI, hash -> (text, lang?, datatype?), built by the parser for string/geometry/typed constants. Lives outside the zero-heap SparqlQueryContext — a cold parse/eval-time structure — so builtins (STR/LANG/DATATYPE/geof:*/…) recover what they need without heap on the §6 hot path.
OrderCondition
ORDER BY condition
SelectQuery
SELECT query
SparqlQueryContext
Flat query context arena - pre-allocated, no heap allocation
StringSink
Query-scoped sink for strings produced by expression evaluation — the result of CONCAT/SUBSTR/UCASE/…, an xsd:dateTime lexical from NOW, a UUID string, or a value-producing BIND. EvalResult only carries a u64 hash, so a produced string must be interned somewhere its hash can be resolved again; this is that table.
TextResolver
Borrowed text resolver threaded into expression evaluation. Resolves a term hash to its literal text via, in order: the query-scoped LiteralTable (query constants), a StringSink of values produced during this query, an optional ingested-data lexicon closure (e.g. wrapping a Q42LexMmap::lookup_hash), and finally the global demo lexicon. Also carries the query-stable now_ms clock and seed used by the temporal / UUID / RAND builtins so their results are referentially transparent within one query snapshot (plan §4.4). All borrowed — no per-query heap in the evaluator, so the §6 hot-path invariant holds.

Enums§

BinaryOp
Binary operators
Expression
Expression - uses ExpressionId for nested expressions
Function
Built-in SPARQL functions
Path
Property path (SPARQL 1.1)
Pattern
Graph pattern - now uses PatternId indices instead of Box
SparqlQuery
SPARQL query forms
TemporalMode
Temporal snapshot mode for AS OF / AT TIME queries.
UnaryOp
Unary operators

Constants§

MAX_BINDINGS
Maximum number of bindings per row
MAX_EXPRESSIONS
Maximum number of expressions in a query context
MAX_ORDER_CONDITIONS
Maximum number of order conditions
MAX_PATTERNS
Maximum number of patterns in a query context
MAX_VARIABLES
Maximum number of variables per query

Traits§

PhysicalOperator
Physical operator trait for query execution

Functions§

literal_term_hash
Query-scoped table of literal text (hash -> string) built by the parser for string/geometry constants. It lives outside the zero-heap SparqlQueryContext — it is a cold parse/eval-time structure — so functions that need literal text (geof:*, STR, REGEX, …) can recover it without putting String/Vec on the zero-heap execution hot path (CLAUDE.md §6). Canonical hash for a literal term, distinguishing a plain literal from a language-tagged or datatype-tagged one ("x", "x"@en, and "x"^^:t are three distinct RDF terms). The parser and the StringSink both use this so a produced STRLANG/STRDT term round-trips its tag.

Type Aliases§

ExpressionId
PathId
PatternId
VariableId