- Record Components:
input- the edge relation; must not be nullfromColumn- the origin node column; must not be blanktoColumn- the destination node column; must not be blankundirected-truereads the two endpoint columns as an undirected edge, so the relation is followed both ways from one edge set (a ↔ b);falsereads a directed edge (a, b)weightColumn- the edge-weight column (must be NUMBER or ANY); must not be blanksense- whether to minimise or maximise total path weight; must not be nullpathColumn- the name of the appended ordered-path array column; must not be blankboundSource- optional literal bound on thefromColumnendpoint (single-source); never null, possibly emptyboundTarget- optional literal bound on thetoColumnendpoint (single-target); never null, possibly emptylocation- the source location of this node; never null
- All Implemented Interfaces:
RelNode
The input() relation is read as a set of directed edges, each
carrying a numeric weight in weightColumn(). The operator computes, for every
reachable (origin, destination) pair, the path that minimises (or maximises,
per sense()) the total edge weight, and returns the traversed node sequence
as a first-class ordered array value in the pathColumn().
Output schema: (fromColumn : T, toColumn : T, weightColumn : NUMBER, pathColumn :
ARRAY),
where T is the type of the endpoint columns and ARRAY is an ordered
array<T> holding the sequence of nodes from origin to destination inclusive.
Evaluation is a Bellman-Ford–style all-pairs fixpoint: each iteration extends
known paths by one hop and keeps the optimal so far. The operator materialises
the complete edge set before iterating, so it is blocking ([bag] mode) and
is subject to the boundedness check. It never pushes down to a source.
MAXIMIZE over a graph with positive-weight cycles will not converge; the
--max-fixpoint-rounds guard applies (consistent with FIX and
weighted CLOSURE).
Surface syntax:
TRACE from, to VIA weight MINIMIZE|MAXIMIZE AS path (Edges)
Pushed endpoint bounds
boundSource() and boundTarget() are optional constant
endpoint bounds folded in by the optimizer's SelectionIntoTracePass
(TRACE-001) when a selection above the trace fixes the origin and/or
destination to a literal. They turn the all-pairs path search into
single-source / single-target / single-pair search — the magic-sets /
sideways-information-passing rewrite specialised to optimal paths. They are
always Optional.empty() on a parsed tree (no surface syntax); they
carry a literal Operand and never change the output schema, so
schema inference is unaffected.
-
Constructor Summary
ConstructorsConstructorDescriptionTraceNode(RelNode input, String fromColumn, String toColumn, boolean undirected, String weightColumn, ObjectiveSense sense, String pathColumn, Optional<Operand> boundSource, Optional<Operand> boundTarget, SourceLocation location) Creates an instance of aTraceNoderecord class.TraceNode(RelNode input, String fromColumn, String toColumn, String weightColumn, ObjectiveSense sense, String pathColumn) Convenience constructor for tests:SourceLocation.UNKNOWN.TraceNode(RelNode input, String fromColumn, String toColumn, String weightColumn, ObjectiveSense sense, String pathColumn, SourceLocation location) Constructor without endpoint bounds (the parsed form): both bounds empty. -
Method Summary
Modifier and TypeMethodDescription<R> Raccept(RelNodeVisitor<R> visitor) Returns the value of theboundSourcerecord component.Returns the value of theboundTargetrecord component.final booleanIndicates whether some other object is "equal to" this one.Returns the value of thefromColumnrecord component.final inthashCode()Returns a hash code value for this object.input()Returns the value of theinputrecord component.location()Returns the value of thelocationrecord component.Returns the value of thepathColumnrecord component.sense()Returns the value of thesenserecord component.toColumn()Returns the value of thetoColumnrecord component.final StringtoString()Returns a string representation of this record class.booleanReturns the value of theundirectedrecord component.Returns the value of theweightColumnrecord component.withBounds(Optional<Operand> newSource, Optional<Operand> newTarget) Returns a copy of this trace with the given endpoint bounds, preserving all other fields.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
-
Constructor Details
-
TraceNode
public TraceNode(RelNode input, String fromColumn, String toColumn, boolean undirected, String weightColumn, ObjectiveSense sense, String pathColumn, Optional<Operand> boundSource, Optional<Operand> boundTarget, SourceLocation location) Creates an instance of aTraceNoderecord class.- Parameters:
input- the value for theinputrecord componentfromColumn- the value for thefromColumnrecord componenttoColumn- the value for thetoColumnrecord componentundirected- the value for theundirectedrecord componentweightColumn- the value for theweightColumnrecord componentsense- the value for thesenserecord componentpathColumn- the value for thepathColumnrecord componentboundSource- the value for theboundSourcerecord componentboundTarget- the value for theboundTargetrecord componentlocation- the value for thelocationrecord component
-
TraceNode
public TraceNode(RelNode input, String fromColumn, String toColumn, String weightColumn, ObjectiveSense sense, String pathColumn, SourceLocation location) Constructor without endpoint bounds (the parsed form): both bounds empty.- Parameters:
input- the edge relation; must not be nullfromColumn- the origin node column; must not be blanktoColumn- the destination node column; must not be blankweightColumn- the edge-weight column; must not be blanksense- the objective sense; must not be nullpathColumn- the appended path-array column; must not be blanklocation- the source location of this node; never null
-
TraceNode
public TraceNode(RelNode input, String fromColumn, String toColumn, String weightColumn, ObjectiveSense sense, String pathColumn) Convenience constructor for tests:SourceLocation.UNKNOWN.
-
-
Method Details
-
withBounds
Returns a copy of this trace with the given endpoint bounds, preserving all other fields.- Parameters:
newSource- the source-endpoint bound; must not be nullnewTarget- the target-endpoint bound; must not be null- Returns:
- a bounded copy
-
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 '=='. -
input
Returns the value of theinputrecord component.- Returns:
- the value of the
inputrecord component
-
fromColumn
Returns the value of thefromColumnrecord component.- Returns:
- the value of the
fromColumnrecord component
-
toColumn
Returns the value of thetoColumnrecord component.- Returns:
- the value of the
toColumnrecord component
-
undirected
public boolean undirected()Returns the value of theundirectedrecord component.- Returns:
- the value of the
undirectedrecord component
-
weightColumn
Returns the value of theweightColumnrecord component.- Returns:
- the value of the
weightColumnrecord component
-
sense
Returns the value of thesenserecord component.- Returns:
- the value of the
senserecord component
-
pathColumn
Returns the value of thepathColumnrecord component.- Returns:
- the value of the
pathColumnrecord component
-
boundSource
Returns the value of theboundSourcerecord component.- Returns:
- the value of the
boundSourcerecord component
-
boundTarget
Returns the value of theboundTargetrecord component.- Returns:
- the value of the
boundTargetrecord component
-
location
Returns the value of thelocationrecord component.
-