Class SchemaAnnotations
java.lang.Object
com.darkcollective.relix.semantic.SchemaAnnotations
A mapping from individual
RelNode instances to their inferred
Schemas.
Keyed by object identity (using an IdentityHashMap), not
structural equality. Two relational algebra nodes that are structurally equal
but reside at different positions in the tree are tracked independently.
The annotation map is populated during schema inference and is then
included in the SemanticModel. Downstream consumers — execution
engines, optimizers, IDEs — can query the schema at any node in any RA
expression tree without re-running inference.
Usage
SchemaAnnotations annotations = model.nodeSchemas();
Schema schema = annotations.get(someNode)
.orElseThrow(() -> new IllegalStateException("schema not inferred for node"));
-
Constructor Summary
ConstructorsConstructorDescriptionCreates an empty annotation map.SchemaAnnotations(Map<RelNode, Schema> initialEntries) Creates an annotation map pre-populated with the supplied entries. -
Method Summary
Modifier and TypeMethodDescriptionasMap()Returns an unmodifiable view of the underlying identity map as a standardMap.static SchemaAnnotationsempty()Returns a new emptySchemaAnnotations.Returns the inferred schema fornode, orOptional.empty()if this node was not annotated (e.g.booleanReturnstrueif a schema has been recorded fornode.Returns the inferred schema fornode, or throws if the node was never annotated.intsize()Returns the number of annotated nodes.
-
Constructor Details
-
SchemaAnnotations
public SchemaAnnotations()Creates an empty annotation map. -
SchemaAnnotations
Creates an annotation map pre-populated with the supplied entries.Entries are keyed by object identity. The caller must supply the exact
RelNodeinstances that will later be looked up viaget(RelNode). Useful for constructing test fixtures without running the full schema-inference pipeline.- Parameters:
initialEntries- node → schema pairs; must not be null
-
-
Method Details
-
empty
Returns a new emptySchemaAnnotations.- Returns:
- an empty annotation map
-
get
Returns the inferred schema fornode, orOptional.empty()if this node was not annotated (e.g. analysis of its subtree failed).- Parameters:
node- the RA node to look up- Returns:
- the schema, or empty
-
require
Returns the inferred schema fornode, or throws if the node was never annotated. Use this from consumers (planner, executor, pushdown) that require every node in a fully-inferred tree to carry a schema; thecontextis appended to the error to identify the calling stage.- Parameters:
node- the RA node to look up; must not be nullcontext- a short phrase describing the calling stage, e.g."during SQL pushdown"- Returns:
- the inferred schema
- Throws:
IllegalStateException- ifnodehas no annotation
-
hasSchema
Returnstrueif a schema has been recorded fornode.- Parameters:
node- the RA node to test- Returns:
- whether an annotation exists
-
size
public int size()Returns the number of annotated nodes.- Returns:
- annotation count
-
asMap
Returns an unmodifiable view of the underlying identity map as a standardMap. Useful for iteration in tests or tooling.- Returns:
- unmodifiable identity map
-