Record Class ColumnStatistics

java.lang.Object
java.lang.Record
com.darkcollective.relix.symbol.ColumnStatistics
Record Components:
distinctCount - the number of distinct (non-null) values, if known
nullCount - the number of NULL values, if known

public record ColumnStatistics(OptionalLong distinctCount, OptionalLong nullCount) extends Record
Per-column statistics used by the cost model to refine cardinality estimates.

Both fields are optional: a -1-style "unknown" is modelled with an empty OptionalLong rather than a sentinel, so a consumer can tell "zero distinct values" from "distinct count not collected".

distinctCount drives the cost model's grouped-aggregation, equi-join and equality-selectivity estimates under the uniformity assumption; nullCount gives IS NULL / IS NOT NULL an exact frequency rather than an assumed one. Neither carries a min/max or a histogram, which is why a range predicate (x > 5) is unestimable and the cost model falls back to a flat selectivity for it.

  • Field Details

    • UNKNOWN

      public static final ColumnStatistics UNKNOWN
      A column-statistics value carrying no information.
  • Constructor Details

    • ColumnStatistics

      public ColumnStatistics(OptionalLong distinctCount, OptionalLong nullCount)
      Creates an instance of a ColumnStatistics record class.
      Parameters:
      distinctCount - the value for the distinctCount record component
      nullCount - the value for the nullCount record component
  • Method Details

    • 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.
    • distinctCount

      public OptionalLong distinctCount()
      Returns the value of the distinctCount record component.
      Returns:
      the value of the distinctCount record component
    • nullCount

      public OptionalLong nullCount()
      Returns the value of the nullCount record component.
      Returns:
      the value of the nullCount record component