Module com.darkcollective.relix.ast
Package com.darkcollective.relix.ast
Record Class SessionizeNode
java.lang.Object
java.lang.Record
com.darkcollective.relix.ast.SessionizeNode
- Record Components:
input- the source relation; must not be nullorderColumn- the column ordering the stream and defining the gap; must not be blankthreshold- the maximum in-session gap (a constantNUMBER/DURATIONliteral); must not be nullpartitionKeys- thePERcolumns; empty = single global partition; must not be nullsessionColumn- the name of the appended session-id column; must not be blanklocation- 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 Summary
ConstructorsConstructorDescriptionSessionizeNode(RelNode input, String orderColumn, Operand threshold, List<String> partitionKeys, String sessionColumn) Convenience constructor for tests:SourceLocation.UNKNOWN.SessionizeNode(RelNode input, String orderColumn, Operand threshold, List<String> partitionKeys, String sessionColumn, SourceLocation location) Creates an instance of aSessionizeNoderecord class. -
Method Summary
Modifier and TypeMethodDescription<R> Raccept(RelNodeVisitor<R> visitor) final booleanIndicates whether some other object is "equal to" this one.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 theorderColumnrecord component.Returns the value of thepartitionKeysrecord component.Returns the value of thesessionColumnrecord component.Returns the value of thethresholdrecord component.final StringtoString()Returns a string representation of this record class.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
-
SessionizeNode
public SessionizeNode(RelNode input, String orderColumn, Operand threshold, List<String> partitionKeys, String sessionColumn, SourceLocation location) Creates an instance of aSessionizeNoderecord class.- Parameters:
input- the value for theinputrecord componentorderColumn- the value for theorderColumnrecord componentthreshold- the value for thethresholdrecord componentpartitionKeys- the value for thepartitionKeysrecord componentsessionColumn- the value for thesessionColumnrecord componentlocation- the value for thelocationrecord component
-
SessionizeNode
public SessionizeNode(RelNode input, String orderColumn, Operand threshold, List<String> partitionKeys, String sessionColumn) Convenience constructor for tests:SourceLocation.UNKNOWN.
-
-
Method Details
-
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. All components in this record class are compared withObjects::equals(Object,Object). -
input
Returns the value of theinputrecord component.- Returns:
- the value of the
inputrecord component
-
orderColumn
Returns the value of theorderColumnrecord component.- Returns:
- the value of the
orderColumnrecord component
-
threshold
Returns the value of thethresholdrecord component.- Returns:
- the value of the
thresholdrecord component
-
partitionKeys
Returns the value of thepartitionKeysrecord component.- Returns:
- the value of the
partitionKeysrecord component
-
sessionColumn
Returns the value of thesessionColumnrecord component.- Returns:
- the value of the
sessionColumnrecord component
-
location
Returns the value of thelocationrecord component.
-