Class RelationBoundedness
- All Implemented Interfaces:
BoundednessSource
relix.relations.boundedness.
It is a BoundednessSource, which is what makes it one answer rather than
two. The lattice, the operator rules and the λ-is-a-rescue exception all live
in PropertyDeriver, and this supplies the part that walk cannot know: what a
leaf is. A leaf here may be a view, so the two call back and forth — the
deriver descends a body, this resolves each name it reaches, and a name that turns out
to be another view is derived in turn.
What a name resolves to
- A view (
:=) — derived from its body, so it is exactly as bounded as what it reads. This is the answer worth having:σ n < 100 (Naturals)is still infinite, andλ 10 (Naturals)is not. - A generator source — asked of the
GeneratorCatalog, the only party that knows.NaturalsandPrimesare unbounded,Rangeis not. - Any other declared relation — a file, an HTTP resource, a database table,
an inline table, a catalog relation — is
Boundedness.BOUNDED. Each is a finite extent that some other party is holding. - A name that resolves to nothing —
Boundedness.UNKNOWN. Unlike the planner's source, which reads an unrecognised leaf as bounded rather than risk refusing a legal query, a catalog has no such stake: it is stating a fact, and the fact about a relation it cannot see is that it does not know one.
A cycle answers UNKNOWN
Mutually recursive definitions (A := σ … (B); B := σ … (A)) terminate on a
visiting set, and re-entering a name in progress yields UNKNOWN rather than the
lattice's identity. RelationDeterminism makes the opposite choice on the same
shape for a good reason that does not hold here: its fold is a conjunction, so the walk
still in progress covers whatever the re-entry would have found. A least upper bound has
no such reading — returning BOUNDED would let a cycle claim to be finite, which
is precisely what nobody can show.
Not thread-safe, and not meant to be: an instance carries the walk it is on, and one is built per analysis.
-
Field Summary
Fields inherited from interface com.darkcollective.relix.cost.BoundednessSource
ALL_BOUNDED -
Constructor Summary
ConstructorsConstructorDescriptionRelationBoundedness(SymbolTable symbols, Map<String, SourceDeclaration> sources, GeneratorCatalog generators) -
Method Summary
Modifier and TypeMethodDescriptionboundednessOf(String relationName) Returns the boundedness of the relation namedrelationName.of(RelationSymbol symbol) Returns the boundedness ofsymbol.
-
Constructor Details
-
RelationBoundedness
public RelationBoundedness(SymbolTable symbols, Map<String, SourceDeclaration> sources, GeneratorCatalog generators) - Parameters:
symbols- resolves a name to its symbol — dotted references included; must not be nullsources- source declarations by canonical (lower-cased) name, as inSemanticModel.sources(), which is where a generator source's name and arguments are; must not be nullgenerators- the installed generators, asked whether one of them is infinite; must not be null (GeneratorCatalog.NONEanswersBoundedness.UNKNOWNfor every generator, which is the honest report from a session with no registry wired in)
-
-
Method Details
-
boundednessOf
Returns the boundedness of the relation namedrelationName.An unresolvable name is
Boundedness.UNKNOWN; seeof(com.darkcollective.relix.symbol.relation.RelationSymbol)for the rest.- Specified by:
boundednessOfin interfaceBoundednessSource- Parameters:
relationName- the relation name, qualified or not; must not be null- Returns:
- the boundedness of the relation named
relationName
-
of
Returns the boundedness ofsymbol.The entry point for a caller that already holds the symbol, which is every caller building a row about a relation rather than following a reference to one — it skips a name resolution that could land on a same-named relation in another namespace.
- Parameters:
symbol- the relation; must not be null- Returns:
- the boundedness of
symbol
-