Package io.prestosql.spi.predicate
Class TupleDomain<T>
- java.lang.Object
-
- io.prestosql.spi.predicate.TupleDomain<T>
-
public final class TupleDomain<T> extends java.lang.Object
Defines a set of valid tuples according to the constraints on each of its constituent columns
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
TupleDomain.ColumnDomain<C>
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static <T> TupleDomain<T>
all()
static <T> TupleDomain<T>
columnWiseUnion(TupleDomain<T> first, TupleDomain<T> second, TupleDomain<T>... rest)
static <T> TupleDomain<T>
columnWiseUnion(java.util.List<TupleDomain<T>> tupleDomains)
Returns a TupleDomain in which corresponding column Domains are unioned together.boolean
contains(TupleDomain<T> other)
Returns true only if the this TupleDomain contains all possible tuples that would be allowable by the other TupleDomain.boolean
equals(java.lang.Object obj)
static <T> java.util.Optional<java.util.Map<T,java.util.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.static <T> java.util.Optional<java.util.Map<T,NullableValue>>
extractFixedValues(TupleDomain<T> tupleDomain)
Extract all column constraints that require exactly one value or only null in their respective Domains.TupleDomain<T>
filter(java.util.function.BiPredicate<T,Domain> predicate)
static <T> TupleDomain<T>
fromColumnDomains(java.util.Optional<java.util.List<TupleDomain.ColumnDomain<T>>> columnDomains)
static <T> TupleDomain<T>
fromFixedValues(java.util.Map<T,NullableValue> fixedValues)
Convert a map of columns to values into the TupleDomain which requires those columns to be fixed to those values.java.util.Optional<java.util.List<TupleDomain.ColumnDomain<T>>>
getColumnDomains()
java.util.Optional<java.util.Map<T,Domain>>
getDomains()
Gets the TupleDomain as a map of each column to its respective Domain.int
hashCode()
TupleDomain<T>
intersect(TupleDomain<T> other)
Returns the strict intersection of the TupleDomains.boolean
isAll()
Returns true if any tuples would satisfy this TupleDomainboolean
isNone()
Returns true if no tuple could ever satisfy this TupleDomainstatic <T> TupleDomain<T>
none()
boolean
overlaps(TupleDomain<T> other)
Returns true only if there exists a strict intersection between the TupleDomains.TupleDomain<T>
simplify()
TupleDomain<T>
simplify(int threshold)
java.lang.String
toString()
java.lang.String
toString(ConnectorSession session)
<U> TupleDomain<U>
transform(java.util.function.Function<T,U> function)
TupleDomain<T>
transformDomains(java.util.function.BiFunction<T,Domain,Domain> transformation)
static <T> TupleDomain<T>
withColumnDomains(java.util.Map<T,Domain> domains)
-
-
-
Method Detail
-
withColumnDomains
public static <T> TupleDomain<T> withColumnDomains(java.util.Map<T,Domain> domains)
-
none
public static <T> TupleDomain<T> none()
-
all
public static <T> TupleDomain<T> all()
-
extractFixedValues
public static <T> java.util.Optional<java.util.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> java.util.Optional<java.util.Map<T,java.util.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(java.util.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
public static <T> TupleDomain<T> fromColumnDomains(java.util.Optional<java.util.List<TupleDomain.ColumnDomain<T>>> columnDomains)
-
getColumnDomains
public java.util.Optional<java.util.List<TupleDomain.ColumnDomain<T>>> getColumnDomains()
-
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 java.util.Optional<java.util.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
-
intersect
public TupleDomain<T> intersect(TupleDomain<T> other)
Returns the strict intersection of the TupleDomains. The resulting TupleDomain represents the set of tuples that would be valid in both TupleDomains.
-
columnWiseUnion
@SafeVarargs public static <T> TupleDomain<T> columnWiseUnion(TupleDomain<T> first, TupleDomain<T> second, TupleDomain<T>... rest)
-
columnWiseUnion
public static <T> TupleDomain<T> columnWiseUnion(java.util.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)
-
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(java.lang.Object obj)
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
toString
public java.lang.String toString(ConnectorSession session)
-
filter
public TupleDomain<T> filter(java.util.function.BiPredicate<T,Domain> predicate)
-
transform
public <U> TupleDomain<U> transform(java.util.function.Function<T,U> function)
-
simplify
public TupleDomain<T> simplify()
-
simplify
public TupleDomain<T> simplify(int threshold)
-
transformDomains
public TupleDomain<T> transformDomains(java.util.function.BiFunction<T,Domain,Domain> transformation)
-
-