Class TupleDomain<T>

java.lang.Object
io.trino.spi.predicate.TupleDomain<T>

public final class TupleDomain<T> extends Object
Defines a set of valid tuples according to the constraints on each of its constituent columns
  • Method Details

    • withColumnDomains

      public static <T> TupleDomain<T> withColumnDomains(Map<T,Domain> domains)
    • none

      public static <T> TupleDomain<T> none()
    • all

      public static <T> TupleDomain<T> all()
    • extractFixedValues

      public static <T> Optional<Map<T,NullableValue>> extractFixedValues(TupleDomain<T> tupleDomain)
      Extract all column constraints that require exactly one value or only null in their respective Domains. Returns an empty Optional if the Domain is none.
    • extractDiscreteValues

      public static <T> Optional<Map<T,List<NullableValue>>> extractDiscreteValues(TupleDomain<T> tupleDomain)
      Extract all column constraints that define a non-empty set of discrete values allowed for the columns in their respective Domains. Returns an empty Optional if the Domain is none.
    • fromFixedValues

      public static <T> TupleDomain<T> fromFixedValues(Map<T,NullableValue> fixedValues)
      Convert a map of columns to values into the TupleDomain which requires those columns to be fixed to those values. Null is allowed as a fixed value.
    • fromColumnDomains

      @Deprecated public static <T> TupleDomain<T> fromColumnDomains(Optional<List<TupleDomain.ColumnDomain<T>>> columnDomains)
      Deprecated.
    • getColumnDomains

      @Deprecated public Optional<List<TupleDomain.ColumnDomain<T>>> getColumnDomains()
      Deprecated.
    • isAll

      public boolean isAll()
      Returns true if any tuples would satisfy this TupleDomain
    • isNone

      public boolean isNone()
      Returns true if no tuple could ever satisfy this TupleDomain
    • getDomains

      public Optional<Map<T,Domain>> getDomains()
      Gets the TupleDomain as a map of each column to its respective Domain. - Will return an Optional.empty() if this is a 'none' TupleDomain. - Unmentioned columns have an implicit value of Domain.all() - The column Domains can be thought of as AND'ed to together to form the whole predicate
    • getDomain

      public Domain getDomain(T column, Type type)
    • intersect

      public <U extends T> TupleDomain<T> intersect(TupleDomain<U> other)
      Returns the strict intersection of the TupleDomains. The resulting TupleDomain represents the set of tuples that would be valid in both TupleDomains.
    • intersect

      public static <T> TupleDomain<T> intersect(List<? extends TupleDomain<? extends T>> domains)
    • columnWiseUnion

      @SafeVarargs public static <T> TupleDomain<T> columnWiseUnion(TupleDomain<T> first, TupleDomain<T> second, TupleDomain<T>... rest)
    • maximal

      public static <T> Optional<TupleDomain<T>> maximal(List<TupleDomain<T>> domains)
      Returns the tuple domain that contains all other tuple domains, or Optional.empty() if they are not supersets of each other.
    • columnWiseUnion

      public static <T> TupleDomain<T> columnWiseUnion(List<TupleDomain<T>> tupleDomains)
      Returns a TupleDomain in which corresponding column Domains are unioned together.

      Note that this is NOT equivalent to a strict union as the final result may allow tuples that do not exist in either TupleDomain. Example 1:

      • TupleDomain X: a => 1, b => 2
      • TupleDomain Y: a => 2, b => 3
      • Column-wise unioned TupleDomain: a => 1 OR 2, b => 2 OR 3

      In the above resulting TupleDomain, tuple (a => 1, b => 3) would be considered valid but would not be valid for either TupleDomain X or TupleDomain Y. Example 2:

      Let a be of type DOUBLE

      • TupleDomain X: (a < 5)
      • TupleDomain Y: (a > 0)
      • Column-wise unioned TupleDomain: (a IS NOT NULL)
      In the above resulting TupleDomain, tuple (a => NaN) would be considered valid but would not be valid for either TupleDomain X or TupleDomain Y. However, this result is guaranteed to be a superset of the strict union.
    • overlaps

      public boolean overlaps(TupleDomain<T> other)
      Returns true only if there exists a strict intersection between the TupleDomains. i.e. there exists some potential tuple that would be allowable in both TupleDomains.
    • contains

      public boolean contains(TupleDomain<T> other)
      Returns true only if the this TupleDomain contains all possible tuples that would be allowable by the other TupleDomain.
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • toString

      public String toString(ConnectorSession session)
    • filter

      public TupleDomain<T> filter(BiPredicate<T,Domain> predicate)
    • transformKeys

      public <U> TupleDomain<U> transformKeys(Function<T,U> function)
    • simplify

      public TupleDomain<T> simplify()
    • simplify

      public TupleDomain<T> simplify(int threshold)
    • transformDomains

      public TupleDomain<T> transformDomains(BiFunction<T,Domain,Domain> transformation)
    • asPredicate

      public Predicate<Map<T,NullableValue>> asPredicate()
    • getRetainedSizeInBytes

      public long getRetainedSizeInBytes(ToLongFunction<T> keySize)