java.lang.Object
com.darkcollective.relix.ast.internal.DisplayLabels

public final class DisplayLabels extends Object
Shared rendering for the sub-expressions that appear inside a node label.

Relix has two tree views: the IR report (:tree), which shows the logical RelNode tree, and the physical plan printer (:explain), which shows the PhysicalNode plan. They are deliberately different at the node level — only :explain names a join algorithm, a build side, or a pushed-down native query — but the structural detail inside a label is the same thing in both, and used to be written out twice by hand. The copies drifted: the same window operator printed WINDOW … SORT … PER … in one view and Window … sort … per … in the other, and the same solver constraint differed in spacing, separator, and even → versus ->.

These renderers are the shared answer, in the language's own spelling — uppercase keywords, glyph arrows, bracketed key lists — so that a construct reads identically wherever it is shown. They take node components rather than nodes, because the logical and physical hierarchies are separate sealed types that happen to embed the same parts.

Physical annotations are not this class's business: a caller appends its own /HASH build=LEFT or streaming on top.

See Also:
  • Method Details

    • bound

      public static String bound(double bound)
      Formats a solver constraint's numeric bound: a finite whole number renders without a fractional part, so 100.0 reads as 100.
      Parameters:
      bound - the constraint bound
      Returns:
      the display text
    • sortKey

      public static String sortKey(SortSpecification spec)
      Renders a sort key as expr↑ (ascending) or expr↓ (descending).
      Parameters:
      spec - the sort specification; must not be null
      Returns:
      the rendered sort key
    • produceBound

      public static String produceBound(ProduceBound produceBound)
      Renders a generator production bound as column ≤ limit.
      Parameters:
      produceBound - the bound; must not be null
      Returns:
      the rendered bound
    • windowFunction

      public static String windowFunction(WindowFunction fn)
      Renders a window function call, e.g. SUM(amount), ROW_NUMBER(), or LAG(price, 1).
      Parameters:
      fn - the window function; must not be null
      Returns:
      the rendered call
    • windowFrame

      public static String windowFrame(WindowFrame frame)
      Renders a window frame as a leading-space suffix — " OVER 3 ROWS", " OVER ALL ROWS", or empty for a whole-partition frame.
      Parameters:
      frame - the frame; must not be null
      Returns:
      the rendered frame, or an empty string
    • window

      public static String window(WindowFunction fn, WindowFrame frame, List<SortSpecification> sortSpecs, List<String> partitionKeys, String outputColumn)
      Renders a complete window operator label, e.g. ROLLING SUM(amount) OVER 3 ROWS SORT ts↑ PER region AS running.

      The keyword is ROLLING for an aggregate window and WINDOW for a ranking or offset function, matching the surface syntax that produces each.

      Parameters:
      fn - the window function; must not be null
      frame - the frame; must not be null
      sortSpecs - the ordering within a partition; must not be null
      partitionKeys - the partition keys, possibly empty; must not be null
      outputColumn - the column the result is written to; must not be null
      Returns:
      the rendered label
    • optimize

      public static String optimize(ObjectiveSense sense, Operand objective, List<OptimizeConstraint> constraints, List<String> groupingKeys, Optional<AllocationSpec> allocation)
      Renders a complete solver label, e.g. OPTIMIZE max SUM(value) s.t. SUM(weight)≤100 [region].
      Parameters:
      sense - maximise or minimise; must not be null
      objective - the objective expression; must not be null
      constraints - the constraints, possibly empty; must not be null
      groupingKeys - the per-group keys, possibly empty; must not be null
      allocation - the continuous-allocation spec, if any; must not be null
      Returns:
      the rendered label