ADR 0002: Zero-Allocation Query Compiler

Status

Accepted

Context

Parsing text strings (like SPARQL-Star or GeoSPARQL) conventionally involves lexing, tokenizing, and constructing an Abstract Syntax Tree (AST). This process rapidly consumes megabytes of heap memory. Under a 512MB RAM ceiling, multiple concurrent queries could easily induce an out-of-memory kernel panic (OOM kill).

Decision

We completely abandon heap-allocated Abstract Syntax Trees. The compiler parses the raw incoming byte stream directly into native 64-bit hardware bitmasks using a finite state machine.

We parse specific nested graph identifiers (like <<?s ?p ?o>>) directly into the NESTED_BIT_MASK flag (1 << 63) on the target vectors. Furthermore, domain-specific logic, such as GeoSPARQL boundaries, are mapped instantly into the SpatiotemporalAmbiguous routing lane (0b11 << 61) without intermediate object allocation.

Consequences