Skip to main content

Crate reifydb_engine

Crate reifydb_engine 

Source
Expand description

Query execution and orchestration. The engine consumes a compiled rql plan, drives the virtual machine over the storage tier, applies policy enforcement, manages per-query session state, and produces the columnar result the caller observes.

Above this crate sit the user-facing surfaces (the SDK, the server subsystems, the subscription/flow runtime); below it sit the storage backends, the catalog, the transaction manager, and the policy evaluator. The engine is the place where a logical query becomes an executed query: instructions are issued to storage, intermediate columns flow through transforms, side effects (writes, schema changes, test runs) are committed under transactional guarantees, and policy checks are interleaved at the points where they can decide what the caller is allowed to see or do.

Invariant: every public entry point that mutates catalog or storage state runs inside a transaction obtained from reifydb-transaction. Bypassing the transaction layer to read or write directly from a backend defeats MVCC, policy enforcement, and CDC capture - all of which assume the engine is the single mediator of those concerns.

Modules§

arena
Bumpalo-backed arena allocator used by the engine for per-request scratch storage. Plans, intermediate column buffers, and the bit-vectors that drive selection live in an arena tied to the request lifetime so the engine can release everything in one bump-reset rather than tracking individual allocations.
bulk_insert
Fast path for inserting many rows at once. Skips the per-row VM dispatch loop, coerces and validates the input batch up front, and writes directly through the storage commit path so a load of a million rows pays a small constant overhead rather than a million instruction-dispatch costs.
engine
environment
error
expression
Runtime expression evaluator. Compiles RQL expressions into a small typed tree that the VM can apply over columns - access, arithmetic, comparison, logical, casts, conversions, lookups, function and routine calls. Evaluation operates on column buffers wherever possible so a per-row interpreter cost is paid only when an expression cannot be vectorised.
flow
Engine-side compiler that turns a CREATE FLOW statement into the dataflow definition the sub-flow runtime consumes. This module is the bridge between RQL’s flow AST and the operator graph the streaming runtime actually evaluates.
policy
Engine-side policy enforcement. Wraps reifydb-policy’s evaluators with the call-sites the VM needs: write policy at commit boundaries, identity policy at session start, callable policy when invoking a routine. Read policy is injected into the plan before execution; this module handles the cases where injection isn’t enough and the engine has to actively gate an operation.
remote
run_tests
Engine-side runner for first-class CREATE TEST / RUN TESTS. Compiles the test body in the active admin transaction and executes it; collects per-test results into the typed result/ types the caller observes. Tests run inside the same transaction as the admin command, so test side effects are visible until the outer transaction commits or rolls back.
session
subscription
test_harness
test_prelude
transaction
Engine-side helpers around the transaction layer. The operation/ submodule wraps the typed catalog and storage operations the VM performs inside a transaction so the dispatch handlers can call them by name rather than wiring up the encoded-key plumbing themselves.
vm
Virtual machine that executes the instruction stream emitted by the planner. The VM owns the per-request lifecycle (admin, command, query, subscription), threads parameters through, walks the plan, dispatches each instruction to its handler, and returns the resulting columns or change deltas to the caller.

Structs§

EngineVersion