Interface Generator
- All Known Implementing Classes:
NaturalsGenerator,PrimesGenerator,RangeGenerator
public interface Generator
A code-backed leaf relation — its rows are produced by engine code rather than
read from a file or database.
A generator owns its schema: schema(Map) returns the heading
the relation will have (used by semantic analysis), and rows(Map, Schema)
lazily produces the tuples (used by execution). Both take the generator's raw
string arguments (e.g. lo/hi/step for Range); a
generator interprets and validates the args it understands.
Layer 0 covers only finite generators, which need no boundedness machinery. Boundedness/distinctness declaration is added in a later slice and consumed by the boundedness check.
-
Method Summary
Modifier and TypeMethodDescriptionThe single column on which this generator emits values in strictly ascending order, when it is an unbounded generator — the seam the optimizer'sGEN-001pass consults to fold an upper-bound selection into a production stop.default OptionalLongcardinality(Map<String, String> args) The generator's exact cardinality for the given arguments, when known — fed to the cost model as an exact row count (a finite generator likeRangeknows it precisely).default booleanWhether this generator is inherently duplicate-free (every row distinct).name()Lazily produces the generator's rows.The schema (heading) this generator produces for the given arguments.default booleanWhether this generator is provably infinite.
-
Method Details
-
name
String name()- Returns:
- the registered generator name (e.g.
"Range"); case-insensitive at lookup
-
schema
The schema (heading) this generator produces for the given arguments. Implementations should keep this total where possible — argument validation that only affects the rows belongs inrows(java.util.Map<java.lang.String, java.lang.String>, com.darkcollective.relix.symbol.Schema).- Parameters:
args- the raw generator arguments- Returns:
- the output schema
-
rows
Lazily produces the generator's rows.- Parameters:
args- the raw generator arguments (e.g.lo/hi/step)schema- the schema returned byschema(Map)for the same args- Returns:
- a lazy stream of rows; the caller closes it
- Throws:
EvaluationException- if the arguments are missing or invalid
-
cardinality
The generator's exact cardinality for the given arguments, when known — fed to the cost model as an exact row count (a finite generator likeRangeknows it precisely). ReturnsOptionalLong.empty()when unknown or unbounded; the default is empty.- Parameters:
args- the raw generator arguments- Returns:
- the exact row count, or empty when unknown/unbounded
-
unbounded
default boolean unbounded()Whether this generator is provably infinite. Read byGeneratorBoundednessSource; finite generators (the default) reportfalse.- Returns:
trueif the generator has no last row
-
duplicateFree
default boolean duplicateFree()Whether this generator is inherently duplicate-free (every row distinct). Read byGeneratorDistinctnessSource, which feeds distinctness-drivenδelimination (DIST-001).- Returns:
trueif the generator never emits a duplicate row
-
ascendingColumn
The single column on which this generator emits values in strictly ascending order, when it is an unbounded generator — the seam the optimizer'sGEN-001pass consults to fold an upper-bound selection into a production stop. Returning a column declares "an upper bound on this column is a sound termination condition" (atakeWhile).The default is empty: finite generators terminate on their own, and a non-monotone generator cannot be safely stopped by a value threshold.
- Returns:
- the ascending value column, or empty when not an ascending unbounded generator
-