Record Class SessionizeNode

java.lang.Object
java.lang.Record
com.darkcollective.relix.ast.SessionizeNode
Record Components:
input - the source relation; must not be null
orderColumn - the column ordering the stream and defining the gap; must not be blank
threshold - the maximum in-session gap (a constant NUMBER/DURATION literal); must not be null
partitionKeys - the PER columns; empty = single global partition; must not be null
sessionColumn - the name of the appended session-id column; must not be blank
location - the source location of this node; never null
All Implemented Interfaces:
RelNode

public record SessionizeNode(RelNode input, String orderColumn, Operand threshold, List<String> partitionKeys, String sessionColumn, SourceLocation location) extends Record implements RelNode
Gap-and-island / sessionization operator — groups an ordered stream into sessions separated by an idle gap, the famous SQL LAG/running-sum incantation expressed as a single algebraic operator.

Within each partition (the optional partitionKeys() — empty means one partition over the whole relation), rows are ordered ascending by the orderColumn() and a new session begins whenever the gap between a row and its predecessor exceeds the threshold():

orderColumnᵢ − orderColumnᵢ₋₁ > threshold
The operator appends a dense, 1-based session-id column (sessionColumn(), type NUMBER) to every input row; the first row of each partition is session 1, and the id increments at every boundary. No row is removed — this is a non-collapsing, column-adding operator (a sibling of the window family).

The orderColumn() is typically a TIMESTAMP (with the gap expressed as a DURATION) or a NUMBER (with a NUMBER gap), leaning on the first-class temporal arithmetic substrate (TIMESTAMP − TIMESTAMP → DURATION).

Surface syntax:

   SESSIONIZE ts GAP DURATION 'PT30M' PER user_id AS session (Events)
   SESSIONIZE seq GAP 5 AS run (Readings)
 

Evaluation buffers and sorts each partition before emitting, so it is a blocking operator (MaterializationMode.BAG); it never pushes down to a source and is subject to the boundedness check over unbounded inputs.

  • Constructor Details

  • Method Details

    • accept

      public <R> R accept(RelNodeVisitor<R> visitor)
      Specified by:
      accept in interface RelNode
    • toString

      public final String 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.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • 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.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      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. All components in this record class are compared with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • input

      public RelNode input()
      Returns the value of the input record component.
      Returns:
      the value of the input record component
    • orderColumn

      public String orderColumn()
      Returns the value of the orderColumn record component.
      Returns:
      the value of the orderColumn record component
    • threshold

      public Operand threshold()
      Returns the value of the threshold record component.
      Returns:
      the value of the threshold record component
    • partitionKeys

      public List<String> partitionKeys()
      Returns the value of the partitionKeys record component.
      Returns:
      the value of the partitionKeys record component
    • sessionColumn

      public String sessionColumn()
      Returns the value of the sessionColumn record component.
      Returns:
      the value of the sessionColumn record component
    • location

      public SourceLocation location()
      Returns the value of the location record component.
      Specified by:
      location in interface RelNode
      Returns:
      the value of the location record component