Record Class RelationStatistics

java.lang.Object
java.lang.Record
com.darkcollective.relix.symbol.RelationStatistics
Record Components:
rowCount - the estimated number of rows, if known
columnStatistics - per-column statistics, keyed by column name; never null
keys - candidate keys (each an ordered list of column names that together uniquely identify a row); never null

public record RelationStatistics(OptionalLong rowCount, Map<String,ColumnStatistics> columnStatistics, List<List<String>> keys) extends Record
Optimizer-facing statistics about a relation — cardinality and structural metadata gathered from a data source (e.g. a database catalog).

Every field is optional or possibly-empty: a value that was not collected is represented by OptionalLong.empty() or an empty collection, never a sentinel. The canonical UNKNOWN instance carries no information and is the safe default for sources that expose no statistics.

  • Field Details

    • UNKNOWN

      public static final RelationStatistics UNKNOWN
      A statistics value carrying no information; the default for stat-less sources.
  • Constructor Details

    • RelationStatistics

      public RelationStatistics(OptionalLong rowCount, Map<String,ColumnStatistics> columnStatistics, List<List<String>> keys)
      Validates and defensively copies the column-statistics map and key lists.
      Parameters:
      rowCount - estimated row count; must not be null
      columnStatistics - column name → statistics; must not be null
      keys - candidate keys; must not be null
  • Method Details

    • of

      public static RelationStatistics of(long rowCount)
      Creates a statistics value carrying only a row count.
      Parameters:
      rowCount - the estimated number of rows; must be non-negative
      Returns:
      a statistics value with the given row count and no other data
    • column

      public Optional<ColumnStatistics> column(String column)
      Returns the statistics for column, if any were collected.
      Parameters:
      column - the column name (case-sensitive, as stored)
      Returns:
      the column statistics, or empty if none were recorded
    • 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.
    • rowCount

      public OptionalLong rowCount()
      Returns the value of the rowCount record component.
      Returns:
      the value of the rowCount record component
    • columnStatistics

      public Map<String,ColumnStatistics> columnStatistics()
      Returns the value of the columnStatistics record component.
      Returns:
      the value of the columnStatistics record component
    • keys

      public List<List<String>> keys()
      Returns the value of the keys record component.
      Returns:
      the value of the keys record component