pub trait ColIndexMappingRewriteExt {
// Required methods
fn rewrite_provided_order(&self, _: &Order) -> Order;
fn rewrite_required_order(&self, _: &Order) -> Option<Order>;
fn rewrite_dist_key(&self, _: &[usize]) -> Option<Vec<usize>>;
fn rewrite_provided_distribution(&self, _: &Distribution) -> Distribution;
fn rewrite_required_distribution(&self, _: &RequiredDist) -> RequiredDist;
fn rewrite_functional_dependency(
&self,
_: &FunctionalDependency,
) -> Option<FunctionalDependency>;
fn rewrite_functional_dependency_set(
&self,
_: FunctionalDependencySet,
) -> FunctionalDependencySet;
fn rewrite_bitset(&self, _: &FixedBitSet) -> FixedBitSet;
fn rewrite_monotonicity_map(&self, _: &MonotonicityMap) -> MonotonicityMap;
}
Expand description
Extension trait for ColIndexMapping
to rewrite frontend structures.
Required Methods§
sourcefn rewrite_provided_order(&self, _: &Order) -> Order
fn rewrite_provided_order(&self, _: &Order) -> Order
Rewrite the provided order’s column index. It will try its best to give the most accurate order. Order(0,1,2) with mapping(0->1,1->0,2->2) will be rewritten to Order(1,0,2) Order(0,1,2) with mapping(0->1,2->0) will be rewritten to Order(1)
sourcefn rewrite_required_order(&self, _: &Order) -> Option<Order>
fn rewrite_required_order(&self, _: &Order) -> Option<Order>
Rewrite the required order’s field index. if it can’t give a corresponding required order after the column index mapping, it will return None. Order(0,1,2) with mapping(0->1,1->0,2->2) will be rewritten to Order(1,0,2) Order(0,1,2) with mapping(0->1,2->0) will return None
sourcefn rewrite_dist_key(&self, _: &[usize]) -> Option<Vec<usize>>
fn rewrite_dist_key(&self, _: &[usize]) -> Option<Vec<usize>>
Rewrite the distribution key and will return None if any index of the key disappear after the mapping.
sourcefn rewrite_provided_distribution(&self, _: &Distribution) -> Distribution
fn rewrite_provided_distribution(&self, _: &Distribution) -> Distribution
Rewrite the provided distribution’s field index. It will try its best to give the most
accurate distribution.
HashShard(0,1,2), with mapping(0->1,1->0,2->2) will be rewritten to HashShard(1,0,2).
HashShard(0,1,2), with mapping(0->1,2->0) will be rewritten to SomeShard
.
sourcefn rewrite_required_distribution(&self, _: &RequiredDist) -> RequiredDist
fn rewrite_required_distribution(&self, _: &RequiredDist) -> RequiredDist
Rewrite the required distribution’s field index. if it can’t give a corresponding
required distribution after the column index mapping, it will return None.
ShardByKey(0,1,2), with mapping(0->1,1->0,2->2) will be rewritten to ShardByKey(1,0,2).
ShardByKey(0,1,2), with mapping(0->1,2->0) will return ShardByKey(1,0).
ShardByKey(0,1), with mapping(2->0) will return Any
.
sourcefn rewrite_functional_dependency(
&self,
_: &FunctionalDependency,
) -> Option<FunctionalDependency>
fn rewrite_functional_dependency( &self, _: &FunctionalDependency, ) -> Option<FunctionalDependency>
Rewrite the indices in a functional dependency.
If some columns in the from
side are removed, then this fd is no longer valid. For
example, for ABC –> D, it means that A, B, and C together can determine C. But if B is
removed, this fd is not valid. For this case, we will return None
Additionally, If the to
side of a functional dependency becomes empty after rewriting, it
means that this dependency is unneeded so we also return None
.
sourcefn rewrite_functional_dependency_set(
&self,
_: FunctionalDependencySet,
) -> FunctionalDependencySet
fn rewrite_functional_dependency_set( &self, _: FunctionalDependencySet, ) -> FunctionalDependencySet
Rewrite functional dependencies in fd_set
one by one, using
[ColIndexMapping::rewrite_functional_dependency]
.
Note that this rewrite process handles each function dependency independently.
Relationships within function dependencies are not considered.
For example, if we have fd_set
{ AB –> C, A –> B }, and column B is removed.
The result would be an empty fd_set
, rather than { A –> C }.