Class GeneratorRegistry
- All Implemented Interfaces:
GeneratorCatalog
Generators, indexed by name (case-insensitive) — the
built-in ones, plus any a program registers.
Also implements the GeneratorCatalog seam, so the same registry that
produces rows at execution supplies generator schemas to semantic analysis —
each generator stays defined in one place. The CLI wires this registry into both
the analyzer (as a GeneratorCatalog) and the
GeneratorDataSourceConnector.
-
Field Summary
Fields inherited from interface com.darkcollective.relix.semantic.internal.GeneratorCatalog
NONE -
Constructor Summary
ConstructorsConstructorDescriptionA registry of the built-in generators: the finiteRangeand the unboundedNaturals/Primes. -
Method Summary
Modifier and TypeMethodDescriptiongeneratorBoundedness(String name, Map<String, String> args) Whether the named generator is finite, for the given arguments — the leaf half ofrelix.relations.boundedness, and the one half no analysis can derive.generatorCardinality(String name, Map<String, String> args) The exact cardinality of the named generator for the given arguments, when known — fed to the cost model so a finite generator (e.g.generatorSchema(String name, Map<String, String> args) Returns the schema of the named generator for the given arguments, orOptional.empty()if the generator is unknown.voidAdds a generator to this registry, under its ownname.
-
Constructor Details
-
GeneratorRegistry
public GeneratorRegistry()A registry of the built-in generators: the finiteRangeand the unboundedNaturals/Primes.
-
-
Method Details
-
register
Adds a generator to this registry, under its ownname.A generator is a code-backed leaf relation, which is exactly what a program supplying rows of its own has: the registry is the one directory both halves of the pipeline read, so registering here is what makes a name resolvable to a heading during analysis and to rows during execution.
A name already taken is rejected rather than replaced. The built-ins are a documented language surface, and a session that silently redefined
Rangewould answer a question about the natural numbers with something else.- Parameters:
generator- the generator to register; must not be null- Throws:
IllegalArgumentException- if a generator of that name is already registered
-
find
- Parameters:
name- the generator name (case-insensitive)- Returns:
- the generator, or empty if none is registered under that name
-
generatorSchema
Description copied from interface:GeneratorCatalogReturns the schema of the named generator for the given arguments, orOptional.empty()if the generator is unknown.- Specified by:
generatorSchemain interfaceGeneratorCatalog- Parameters:
name- the generator name (e.g."Range"); case-insensitiveargs- the raw generator arguments- Returns:
- the generator's output schema, or empty if unknown
-
generatorCardinality
Description copied from interface:GeneratorCatalogThe exact cardinality of the named generator for the given arguments, when known — fed to the cost model so a finite generator (e.g.Range) has an exact row count. ReturnsOptionalLong.empty()for an unknown generator or an unbounded/unknown cardinality; the default is empty.- Specified by:
generatorCardinalityin interfaceGeneratorCatalog- Parameters:
name- the generator name; case-insensitiveargs- the raw generator arguments- Returns:
- the exact row count, or empty
-
generatorBoundedness
Description copied from interface:GeneratorCatalogWhether the named generator is finite, for the given arguments — the leaf half ofrelix.relations.boundedness, and the one half no analysis can derive.It rides this seam for the reason
GeneratorCatalog.generatorCardinality(java.lang.String, java.util.Map<java.lang.String, java.lang.String>)does: a generator's finiteness is declared by the generator, which lives above this module, and the registry that produces its rows is the same object that answers here — so the two halves of the pipeline cannot disagree about which relations are infinite.The default is
Boundedness.UNKNOWN, which is what a catalog that knows no generators honestly has to say. That is not the conservatism the planner wants: a check that refuses an unbounded input reads an unrecognised leaf asBOUNDEDrather than risk rejecting a legal query, while a catalog reporting a fact about a generator it has never heard of would simply be making it up.- Specified by:
generatorBoundednessin interfaceGeneratorCatalog- Parameters:
name- the generator name; case-insensitiveargs- the raw generator arguments- Returns:
- its boundedness, or
Boundedness.UNKNOWNfor a generator this catalog does not know
-