Interface RelTrait
- All Known Subinterfaces:
Convention
,RelCollation
,RelDistribution
,RelMultipleTrait
- All Known Implementing Classes:
BindableConvention
,Convention.Impl
,EnumerableConvention
,InterpretableConvention
,JdbcConvention
,RelCollationImpl
CallingConvention.JAVA
is a trait
of the ConventionTraitDef
trait definition.
Note about equals() and hashCode()
If all instances of RelTrait for a particular RelTraitDef are defined in
an enum
and no new RelTraits can be introduced at runtime, you need
not override hashCode()
and equals(Object)
. If, however,
new RelTrait instances are generated at runtime (e.g. based on state external
to the planner), you must implement hashCode()
and
equals(Object)
for proper canonization
of your RelTrait objects.
-
Method Summary
Modifier and TypeMethodDescriptiondefault <T extends RelTrait>
Tapply
(Mappings.TargetMapping mapping) Applies a mapping to this trait.boolean
Returns the RelTraitDef that defines this RelTrait.int
hashCode()
default boolean
Returns whether this trait is the default trait value.void
register
(RelOptPlanner planner) Registers a trait instance with the planner.boolean
Returns whether this trait satisfies a given trait.toString()
Returns a succinct name for this trait.
-
Method Details
-
getTraitDef
RelTraitDef getTraitDef()Returns the RelTraitDef that defines this RelTrait.- Returns:
- the RelTraitDef that defines this RelTrait
-
hashCode
int hashCode() -
equals
-
satisfies
Returns whether this trait satisfies a given trait.A trait satisfies another if it is the same or stricter. For example,
ORDER BY x, y
satisfiesORDER BY x
.A trait's
satisfies
relation must be a partial order (reflexive, anti-symmetric, transitive). Many traits cannot be "loosened"; theirsatisfies
is an equivalence relation, where only X satisfies X.If a trait has multiple values (see
RelCompositeTrait
) a collection (T0, T1, ...) satisfies T if any Ti satisfies T.- Parameters:
trait
- Given trait- Returns:
- Whether this trait subsumes a given trait
-
toString
String toString()Returns a succinct name for this trait. The planner may use this String to describe the trait. -
register
Registers a trait instance with the planner.This is an opportunity to add rules that relate to that trait. However, typical implementations will do nothing.
- Parameters:
planner
- Planner
-
apply
Applies a mapping to this trait.Some traits may be changed if the columns order is changed by a mapping of the
Project
operator.For example, if relation
SELECT a, b ORDER BY a, b
is sorted by columns [0, 1], then the projectSELECT b, a
over this relation will be sorted by columns [1, 0]. In the same time projectSELECT b
will not be sorted at all because it doesn't contain the collation prefix and this method will return an empty collation.Other traits are independent from the columns remapping. For example
Convention
orRelDistributions.SINGLETON
.- Parameters:
mapping
- Mapping- Returns:
- trait with mapping applied
-
isDefault
default boolean isDefault()Returns whether this trait is the default trait value.
-