Module com.darkcollective.relix.ast
Package com.darkcollective.relix.ast
Record Class TruthRelationNode
java.lang.Object
java.lang.Record
com.darkcollective.relix.ast.TruthRelationNode
- Record Components:
holdsTuple-trueforUNIT/DEE(one empty tuple),falseforEMPTY/DUM(no tuples)location- the source location of this node; never null
- All Implemented Interfaces:
RelNode
public record TruthRelationNode(boolean holdsTuple, SourceLocation location)
extends Record
implements RelNode
A nullary truth relation literal — a leaf node denoting one of the two
relations whose heading is the empty (closed, zero-column) schema.
A zero-column relation can hold at most one tuple — the empty tuple — so there are exactly two of them, and they behave as truth values:
UNIT(aliasDEE) — holds the empty tuple: true, and the identity of Cartesian product (R × UNIT = R).EMPTY(aliasDUM) — holds no tuple: false.R × EMPTYis empty, but it keepsR's heading, so it is notEMPTYitself.
These are Tutorial D's TABLE_DEE / TABLE_DUM (Date &
Darwen, The Third Manifesto). Relix leads with the descriptive
UNIT/EMPTY spellings — the lineage names are recognised
aliases, in the same spirit as the glyph↔keyword duality of the operators.
The empty schema this node infers to (Schema.empty()) is the same
one the no-key whole-relation universal quantifier ∀ : P (R) already
produces, so every phase below is width-0 tolerant by construction.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionTruthRelationNode(boolean holdsTuple, SourceLocation location) Creates an instance of aTruthRelationNoderecord class. -
Method Summary
Modifier and TypeMethodDescription<R> Raccept(RelNodeVisitor<R> visitor) longThe number of tuples this literal denotes:1forUNIT,0forEMPTY.static TruthRelationNodeempty(SourceLocation location) Creates the zero-tuple truth relation (EMPTY/DUM).final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.booleanReturns the value of theholdsTuplerecord component.keyword()Returns the canonical keyword for this literal —"UNIT"or"EMPTY"— as printed by every tree renderer.location()Returns the value of thelocationrecord component.final StringtoString()Returns a string representation of this record class.static TruthRelationNodeunit(SourceLocation location) Creates the one-tuple truth relation (UNIT/DEE).Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface com.darkcollective.relix.ast.RelNode
children, mapChildren, materializationMode, prettyPrint
-
Field Details
-
UNIT_KEYWORD
The keyword spelling of the one-tuple truth relation.- See Also:
-
EMPTY_KEYWORD
The keyword spelling of the zero-tuple truth relation.- See Also:
-
-
Constructor Details
-
TruthRelationNode
Creates an instance of aTruthRelationNoderecord class.- Parameters:
holdsTuple- the value for theholdsTuplerecord componentlocation- the value for thelocationrecord component
-
-
Method Details
-
unit
Creates the one-tuple truth relation (UNIT/DEE).- Parameters:
location- the source location; must not be null- Returns:
- a
UNITnode
-
empty
Creates the zero-tuple truth relation (EMPTY/DUM).- Parameters:
location- the source location; must not be null- Returns:
- an
EMPTYnode
-
keyword
Returns the canonical keyword for this literal —"UNIT"or"EMPTY"— as printed by every tree renderer.- Returns:
- the canonical keyword; never null
-
cardinality
public long cardinality()The number of tuples this literal denotes:1forUNIT,0forEMPTY. Both cardinalities are exact, not estimates.- Returns:
1or0
-
accept
-
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 '=='. -
holdsTuple
public boolean holdsTuple()Returns the value of theholdsTuplerecord component.- Returns:
- the value of the
holdsTuplerecord component
-
location
Returns the value of thelocationrecord component.
-