java.lang.Object
java.lang.Record
com.darkcollective.relix.processor.exec.SetRelation
Record Components:
schema - the schema shared by all rows; never null
rows - the set of unique rows; stored as an unmodifiable view of a LinkedHashSet; never null
All Implemented Interfaces:
MaterializedRelation

public record SetRelation(Schema schema, SequencedSet<Row> rows) extends Record implements MaterializedRelation
A materialised relation that contains only unique rows, preserving the order in which rows were first inserted — the Set type in the IBM flat-collection taxonomy (No Key, Element Equality, Unordered, Unique).

Row equality is structural: two rows are equal if they have the same schema and all corresponding values are equal (as defined by Row.equals). LinkedHashSet is used as the backing store so that insertion order is stable across executions.

This is the natural output type for:

  • DISTINCT (deduplication of an input bag).
  • UNION (deduplication of two concatenated inputs).
  • INTERSECTION (rows common to both inputs).
  • DIFFERENCE (rows in the left input not in the right).
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates an instance of a SetRelation record class.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    Returns true if this set contains a row structurally equal to row.
    final boolean
    Indicates whether some other object is "equal to" this one.
    final int
    Returns a hash code value for this object.
    of(Schema schema, Iterable<Row> source)
    Builds a SetRelation from an ordered stream of rows, silently discarding any duplicates (later occurrences of a row that has already been seen are dropped).
    Returns the value of the rows record component.
    Returns the value of the schema record component.
    int
    Number of unique rows.
    Returns a lazy stream over all rows in this relation.
    final String
    Returns a string representation of this record class.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • SetRelation

      public SetRelation(Schema schema, SequencedSet<Row> rows)
      Creates an instance of a SetRelation record class.
      Parameters:
      schema - the value for the schema record component
      rows - the value for the rows record component
  • Method Details

    • of

      public static SetRelation of(Schema schema, Iterable<Row> source)
      Builds a SetRelation from an ordered stream of rows, silently discarding any duplicates (later occurrences of a row that has already been seen are dropped).
    • contains

      public boolean contains(Row row)
      Returns true if this set contains a row structurally equal to row.
    • size

      public int size()
      Number of unique rows.
    • stream

      public Stream<Row> stream()
      Description copied from interface: MaterializedRelation
      Returns a lazy stream over all rows in this relation. The stream may be consumed exactly once.
      Specified by:
      stream in interface MaterializedRelation
    • 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.
    • schema

      public Schema schema()
      Returns the value of the schema record component.
      Specified by:
      schema in interface MaterializedRelation
      Returns:
      the value of the schema record component
    • rows

      public SequencedSet<Row> rows()
      Returns the value of the rows record component.
      Returns:
      the value of the rows record component