Record Class ExecutionContext
- Record Components:
symbolTable- the fully-populated symbol table; must not benullnodeSchemas- per-node schema annotations from inference; must not benullstatistics- per-relation statistics for the planner's cost model; must not benullsources- canonical name → source declaration, for SQL pushdown planning; must not benullconnections- canonical name → connection declaration, for SQL pushdown planning; must not benullconnector- the data-source connector for external relations; must not benulllistener- observer notified of execution-stageQueryEvents (e.g. a declarative-optimisation group skipped as infeasible);QueryEventListener.NONEto ignore them; must not benullmaxFixpointRounds- maximum number of semi-naïve fixpoint iterations before aborting with anEvaluationException; useUNLIMITED_FIXPOINT_ROUNDSfor no cap (the default); must be ≥ 1maxMaterializedRows- maximum rows a single blocking operator (γ, τ, a deduplicating set operation, a hash join's build side, …) may buffer before aborting with anEvaluationExceptionnaming it. Bounds one operator rather than a run's total, exactly asmaxFixpointRoundsbounds one fixpoint; useUNLIMITED_MATERIALIZED_ROWSfor no cap (the default); must be ≥ 1maxProcessedRows- maximum rows one execution's operators may pass to one another in total before aborting with anEvaluationException: a deterministic measure of work, which stops a query that runs long while producing little. UseUNLIMITED_PROCESSED_ROWSfor no cap (the default); must be ≥ 1timeout- how long one execution may run before aborting with anEvaluationException, checked as rows pass between operators; useUNLIMITED_TIMEOUTfor none (the default); must be positiveclock- the clock the current-time built-ins (NOW,CURRENT_DATE,CURRENT_TIME) read. Read once, when the context is made: what the context keeps is that instant, so every row of every query run through it sees the same moment. Supplying a pinned clock (seewithClock(java.time.Clock)) additionally makes the run reproducible — the same script over the same data yields the same rows however much later it is replayed.Clock.systemUTC()by default; must not benullfunctions- the function catalogue every call is evaluated against — the same one the model was analysed against, so analysis and evaluation cannot disagree about what a name means.of(SemanticModel, DataSourceConnector)takes it from the model; a context built without one getsinstalledFunctions(). Must not benull
An ExecutionContext bundles the three things an operator may need
at runtime:
symbolTable()— used byRelationExecutorto resolve a relation name to its symbol (inline rows, query body, or external source).nodeSchemas()— the per-node schema annotations produced by semantic analysis; used to constructRowobjects with the correct column set when opening a source.connector()— called only forDatabaseRelationSymbolandSourceRelationSymbolrelations that require external I/O. Inline relations are served directly from the symbol table without calling the connector.
Construction
Prefer the factory methods over the canonical record constructor:
of(SemanticModel, DataSourceConnector)— normal use; extracts the relevant fields from a validatedSemanticModel.inlineOnly(SemanticModel)— convenience for scripts that contain only inline relations; any attempt to open an external source throwsEvaluationException.
Precondition
The executor assumes it receives a fully valid
SemanticModel. Passing an unvalidated model (e.g.
result.isFullyValid() == false) may cause
EvaluationExceptions that should have been caught during semantic
analysis.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intThe buffer a blocking operator is allowed by default — ten million rows.static final intSentinel value meaning no cap on fixpoint iteration rounds; also the default.static final intSentinel value meaning no cap on a blocking operator's buffer.static final longNo cap on the rows one execution's operators may process, which is the default.static final DurationNo timeout on one execution, which is the default. -
Constructor Summary
ConstructorsConstructorDescriptionExecutionContext(SymbolTable symbolTable, SchemaAnnotations nodeSchemas, DataSourceConnector connector) Convenience constructor for contexts with no statistics and no pushdown metadata (the planner uses tier-based cost only and never pushes SQL).ExecutionContext(SymbolTable symbolTable, SchemaAnnotations nodeSchemas, Map<String, RelationStatistics> statistics, Map<String, SourceDeclaration> sources, Map<String, ConnectionDeclaration> connections, DataSourceConnector connector) Convenience constructor that observes no execution events (QueryEventListener.NONE) and imposes no fixpoint cap.ExecutionContext(SymbolTable symbolTable, SchemaAnnotations nodeSchemas, Map<String, RelationStatistics> statistics, Map<String, SourceDeclaration> sources, Map<String, ConnectionDeclaration> connections, DataSourceConnector connector, QueryEventListener listener, int maxFixpointRounds, int maxMaterializedRows, long maxProcessedRows, Duration timeout, Clock clock, FunctionCatalog functions) Creates an instance of aExecutionContextrecord class. -
Method Summary
Modifier and TypeMethodDescriptionThe per-leafBoundednessSourcefor this context — a generator source reports its declared boundedness, every other leaf is bounded.clock()Returns the value of theclockrecord component.Returns the value of theconnectionsrecord component.Returns the value of theconnectorrecord component.final booleanIndicates whether some other object is "equal to" this one.The ambient state a function implementation may read while it runs — today the clock, so a pinned run is reproducible down toNOW().Returns the value of thefunctionsrecord component.final inthashCode()Returns a hash code value for this object.static ExecutionContextinlineOnly(SemanticModel model) Creates anExecutionContextfor scripts that contain only inline relations.static FunctionCatalogThe catalogue over whichever function libraries are installed, discovered once.listener()Returns the value of thelistenerrecord component.intReturns the value of themaxFixpointRoundsrecord component.intReturns the value of themaxMaterializedRowsrecord component.longReturns the value of themaxProcessedRowsrecord component.Returns the value of thenodeSchemasrecord component.static ExecutionContextof(SemanticModel model, DataSourceConnector connector) Creates anExecutionContextfrom a validatedSemanticModeland aDataSourceConnectorfor external relations.static ExecutionContextof(SemanticModel model, SchemaAnnotations nodeSchemas, DataSourceConnector connector) Creates anExecutionContextfrom a model and connector but with an overriding set of schema annotations — used when executing an optimizer-rewritten tree whose nodes are absent fromSemanticModel.nodeSchemas().sources()Returns the value of thesourcesrecord component.Returns the value of thestatisticsrecord component.Returns the value of thesymbolTablerecord component.timeout()Returns the value of thetimeoutrecord component.final StringtoString()Returns a string representation of this record class.Returns a copy of this context whose current-time built-ins readclock.withFunctions(FunctionCatalog functions) Returns a copy of this context whose function calls are evaluated againstfunctions.withListener(QueryEventListener listener) Returns a copy of this context that emits execution-stage events tolistener.withMaxFixpointRounds(int maxFixpointRounds) Returns a copy of this context with the given fixpoint-iteration cap.withMaxMaterializedRows(int maxMaterializedRows) Returns a copy of this context with the given cap on how many rows one blocking operator may buffer.withMaxProcessedRows(long maxProcessedRows) Returns a copy of this context with the given cap on the rows one execution may process.withTimeout(Duration timeout) Returns a copy of this context with the given limit on how long one execution may run.
-
Field Details
-
UNLIMITED_FIXPOINT_ROUNDS
public static final int UNLIMITED_FIXPOINT_ROUNDSSentinel value meaning no cap on fixpoint iteration rounds; also the default.- See Also:
-
UNLIMITED_MATERIALIZED_ROWS
public static final int UNLIMITED_MATERIALIZED_ROWSSentinel value meaning no cap on a blocking operator's buffer.- See Also:
-
DEFAULT_MAX_MATERIALIZED_ROWS
public static final int DEFAULT_MAX_MATERIALIZED_ROWSThe buffer a blocking operator is allowed by default — ten million rows.A cap and a sentinel are not the same decision. Passing
UNLIMITED_MATERIALIZED_ROWSstill means no cap; this is what a context that names no number gets, and until now that was the sentinel.The number is chosen to be one no reasonable query reaches and every runaway does. What it buys is not memory — ten million rows is a great deal of memory — but attribution: past it the query fails naming the operator that buffered and the knob that raises the limit, where before the host JVM died with an
OutOfMemoryErrorbelonging to nobody. This engine runs inside someone else's process, so that error takes their program down and tells them nothing.The fixpoint round count is deliberately not given the same treatment. How many rounds a legitimate recursion needs is a property of the data — a transitive closure over a long chain needs one round per hop — so any default there refuses some correct query, and a truncated answer is harder to diagnose than a hang.
UNLIMITED_FIXPOINT_ROUNDSremains the default and stays opt-in.- See Also:
-
UNLIMITED_PROCESSED_ROWS
public static final long UNLIMITED_PROCESSED_ROWSNo cap on the rows one execution's operators may process, which is the default.- See Also:
-
UNLIMITED_TIMEOUT
No timeout on one execution, which is the default.
-
-
Constructor Details
-
ExecutionContext
public ExecutionContext(SymbolTable symbolTable, SchemaAnnotations nodeSchemas, Map<String, RelationStatistics> statistics, Map<String, SourceDeclaration> sources, Map<String, ConnectionDeclaration> connections, DataSourceConnector connector, QueryEventListener listener, int maxFixpointRounds, int maxMaterializedRows, long maxProcessedRows, Duration timeout, Clock clock, FunctionCatalog functions) Creates an instance of aExecutionContextrecord class.- Parameters:
symbolTable- the value for thesymbolTablerecord componentnodeSchemas- the value for thenodeSchemasrecord componentstatistics- the value for thestatisticsrecord componentsources- the value for thesourcesrecord componentconnections- the value for theconnectionsrecord componentconnector- the value for theconnectorrecord componentlistener- the value for thelistenerrecord componentmaxFixpointRounds- the value for themaxFixpointRoundsrecord componentmaxMaterializedRows- the value for themaxMaterializedRowsrecord componentmaxProcessedRows- the value for themaxProcessedRowsrecord componenttimeout- the value for thetimeoutrecord componentclock- the value for theclockrecord componentfunctions- the value for thefunctionsrecord component
-
ExecutionContext
public ExecutionContext(SymbolTable symbolTable, SchemaAnnotations nodeSchemas, Map<String, RelationStatistics> statistics, Map<String, SourceDeclaration> sources, Map<String, ConnectionDeclaration> connections, DataSourceConnector connector) Convenience constructor that observes no execution events (QueryEventListener.NONE) and imposes no fixpoint cap. Keeps the common construction path — and every existing call site — free of those parameters.- Parameters:
symbolTable- the fully-populated symbol table; must not benullnodeSchemas- per-node schema annotations; must not benullstatistics- per-relation statistics; must not benullsources- canonical name → source declaration; must not benullconnections- canonical name → connection declaration; must not benullconnector- the data-source connector; must not benull
-
ExecutionContext
public ExecutionContext(SymbolTable symbolTable, SchemaAnnotations nodeSchemas, DataSourceConnector connector) Convenience constructor for contexts with no statistics and no pushdown metadata (the planner uses tier-based cost only and never pushes SQL).- Parameters:
symbolTable- the fully-populated symbol table; must not benullnodeSchemas- per-node schema annotations; must not benullconnector- the data-source connector; must not benull
-
-
Method Details
-
functionContext
The ambient state a function implementation may read while it runs — today the clock, so a pinned run is reproducible down toNOW().It also carries the engine's total order over values, which is what an aggregate that ranks its input —
MIN,ARGMAX— reduces by.Build it once per execution and hold it: it is a field of the evaluator, not something to make per call.
- Returns:
- the function context for this execution
-
installedFunctions
The catalogue over whichever function libraries are installed, discovered once.Discovery scans the module path, so doing it per context — let alone per query — would be paid for on every run. It is also the answer that must not vary: two catalogues assembled separately can disagree about what a name means. A context built from a
SemanticModeluses that model's catalogue instead, which is the same one analysis resolved against.- Returns:
- the catalogue of installed function libraries
-
boundedness
The per-leafBoundednessSourcefor this context — a generator source reports its declared boundedness, every other leaf is bounded. Used by the planner's materialisation-safety check and join build-side rule. Derived fromsources(), so it needs no extra construction or threading.- Returns:
- the boundedness source for the relations in this context
-
withListener
Returns a copy of this context that emits execution-stage events tolistener. All other fields are shared unchanged.- Parameters:
listener- the observer to attach; must not benull- Returns:
- a new context with the given listener
-
withMaxFixpointRounds
Returns a copy of this context with the given fixpoint-iteration cap. All other fields are shared unchanged.- Parameters:
maxFixpointRounds- the maximum number of semi-naïve fixpoint iterations allowed before anEvaluationExceptionis thrown; must be ≥ 1; useUNLIMITED_FIXPOINT_ROUNDSfor no cap- Returns:
- a new context with the given limit
-
withMaxMaterializedRows
Returns a copy of this context with the given cap on how many rows one blocking operator may buffer. All other fields are shared unchanged.The guard for the failure a plan cannot see.
BoundednessCheckerrefuses a blocking operator over an unbounded input, and a collecting terminal refuses to gather one; neither says anything about size, so a bounded table far larger than the heap plans happily and dies with anOutOfMemoryErrorattributable to no operator in particular. Under a cap the same query stops with anEvaluationExceptionnaming the operator that was buffering.It bounds one operator's buffer rather than a run's total — the shape
withMaxFixpointRounds(int)has, which likewise bounds one fixpoint. A running total would refuse a fixpoint that buffers the same thousand rows each round without its peak memory ever moving.- Parameters:
maxMaterializedRows- the maximum rows a single blocking operator may buffer; must be ≥ 1; useUNLIMITED_MATERIALIZED_ROWSfor no cap- Returns:
- a new context with the given limit
-
withMaxProcessedRows
Returns a copy of this context with the given cap on the rows one execution may process. All other fields are shared unchanged.A row is counted each time an operator hands one to the operator above it, so the count is the sum of every operator's output. That is what stops the two queries a cap on output cannot: a selection over an endless generator that matches nothing, and an aggregate over a large product that emits a single row. It is a running total for the whole execution, recursion included, because what it bounds is work done rather than memory held.
- Parameters:
maxProcessedRows- the maximum rows processed; must be ≥ 1; useUNLIMITED_PROCESSED_ROWSfor no cap- Returns:
- a new context with the given limit
-
withTimeout
Returns a copy of this context with the given limit on how long one execution may run. All other fields are shared unchanged.The clock starts when execution does, not when planning does. It is checked as rows pass between operators, so it cannot interrupt a call that does not return to the engine: a JDBC driver waiting on its database, or a solver's search.
- Parameters:
timeout- the longest one execution may run; must be positive; useUNLIMITED_TIMEOUTfor none- Returns:
- a new context with the given limit
-
withClock
Returns a copy of this context whose current-time built-ins readclock. All other fields are shared unchanged.This is the reproducibility seam: pin the clock and
NOW(),CURRENT_DATE()andCURRENT_TIME()become fixed for the whole run, so a script with a relative time window (NOW() - DURATION 'PT1H') selects the same rows today and next month. The CLI exposes it as--now/RELIX_NOW.The functions stay non-
PUREand non-DETERMINISTICin the registry regardless: under the default clock they still advance, so the optimizer must never fold or dedupe them.- Parameters:
clock- the clock to read; must not benull- Returns:
- a new context reading the given clock
-
withFunctions
Returns a copy of this context whose function calls are evaluated againstfunctions. All other fields are shared unchanged.The catalogue normally arrives from the analysed model, which is what keeps analysis and evaluation agreeing about what a name means. Overriding it is for a caller that assembled its own — an embedder installing a library programmatically rather than through discovery.
- Parameters:
functions- the catalogue to evaluate calls against; must not benull- Returns:
- a new context over the given catalogue
-
of
Creates anExecutionContextfrom a validatedSemanticModeland aDataSourceConnectorfor external relations. Pulls statistics, sources, and connections from the model so cost-based planning and SQL pushdown are enabled.- Parameters:
model- the fully-validated semantic model; must not benullconnector- the connector supplying external rows; must not benull- Returns:
- a new context
-
of
public static ExecutionContext of(SemanticModel model, SchemaAnnotations nodeSchemas, DataSourceConnector connector) Creates anExecutionContextfrom a model and connector but with an overriding set of schema annotations — used when executing an optimizer-rewritten tree whose nodes are absent fromSemanticModel.nodeSchemas().- Parameters:
model- the semantic model; must not benullnodeSchemas- the annotations covering the tree to execute; must not benullconnector- the connector supplying external rows; must not benull- Returns:
- a new context
-
inlineOnly
Creates anExecutionContextfor scripts that contain only inline relations. Any attempt to open an external data source via the connector throwsEvaluationException.- Parameters:
model- the fully-validated semantic model; must not benull- Returns:
- a new context whose connector rejects all external source requests
-
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared withObjects::equals(Object,Object); primitive components are compared with '=='. -
symbolTable
Returns the value of thesymbolTablerecord component.- Returns:
- the value of the
symbolTablerecord component
-
nodeSchemas
Returns the value of thenodeSchemasrecord component.- Returns:
- the value of the
nodeSchemasrecord component
-
statistics
Returns the value of thestatisticsrecord component.- Returns:
- the value of the
statisticsrecord component
-
sources
Returns the value of thesourcesrecord component.- Returns:
- the value of the
sourcesrecord component
-
connections
Returns the value of theconnectionsrecord component.- Returns:
- the value of the
connectionsrecord component
-
connector
Returns the value of theconnectorrecord component.- Returns:
- the value of the
connectorrecord component
-
listener
Returns the value of thelistenerrecord component.- Returns:
- the value of the
listenerrecord component
-
maxFixpointRounds
public int maxFixpointRounds()Returns the value of themaxFixpointRoundsrecord component.- Returns:
- the value of the
maxFixpointRoundsrecord component
-
maxMaterializedRows
public int maxMaterializedRows()Returns the value of themaxMaterializedRowsrecord component.- Returns:
- the value of the
maxMaterializedRowsrecord component
-
maxProcessedRows
public long maxProcessedRows()Returns the value of themaxProcessedRowsrecord component.- Returns:
- the value of the
maxProcessedRowsrecord component
-
timeout
Returns the value of thetimeoutrecord component.- Returns:
- the value of the
timeoutrecord component
-
clock
Returns the value of theclockrecord component.- Returns:
- the value of the
clockrecord component
-
functions
Returns the value of thefunctionsrecord component.- Returns:
- the value of the
functionsrecord component
-