uk.ac.bbk.dcs.automed.qproc.optimise.optimisers
Class RelationSKJEliminator
java.lang.Object
uk.ac.bbk.dcs.automed.qproc.optimise.optimisers.RelationSKJEliminator
public class RelationSKJEliminator
- extends java.lang.Object
This class removes self-join of relations over their key arising from the AutoMed relational model encoding
For example, [{k1,n,m}|{p1,n}<-[{{k1,..,kn},a1}|{k1,..,kn,a1,a2}<-<>]; {p2,m}<-[{{k1,..,kn},a2}|{k1,..,kn,a1,a2}<-<>];
p1 = p2]
becomes:
[{{k1,...,kn},a1,a2}|{k1,..,kn,a1,a2}<-<>]
Although table <> may contain several key attributes, we assume that {p1,n} and {p2,m} will be pair
The steps for the simplification are:
1. Method isRelTableStrComp checks if a comp is a RelTableStrComp which is generated by AutoMed relational wrappers, like:
[{{k1,..,kn},ai}|{k1,..,kn,a1,a2,...,an}<-S1:<>]
2. Methods unifyVarInRelTableStrComp and mappingVarsInRelTableStrGen rename vars in all RelTableStrComp in the comprehension,
and map the vars in the main comp to the vars in the sub RelTableStrComp:
[h|{p11,a11,a12,...,a1n} <- [{{k1,...,kp},ai}|{k1,...,kp,a1,...,am}<-<>]; {p21,a21,a22,...,a2n} <-
[{{k1,...,kq},aj}|{k1,...,kq,a1,...,an}<-<>]; ... P]
changes into:
[h|{p11,a11,a12,...,a1n} <- [{{$un_R1_k1_1,...,$un_R1_kp_1},$un_R1_ai_1}|
{$un_R1_k1_1,...,$un_R1_kp_1,$un_R1_a1_1,...,$un_R1_am_1}<-<>]; {p21,a21,a22,...,a2n} <-
[{{$un_R2_k1_2,...,$un_R2_kq_2},$un_R2_aj_2}| {$un_R2_k1_2,...,$un_R2_kq_2,$un_R2_a1_2,...,$un_R2_an_2}<-<>]; ... P]
3. Method isTwoEquivalentKey checks self-Key-Join generators which are generated from the same RelTableStrComp and having the
equator between their keys
[h|{p11,a11}<-RelTableStrComp1;{p12,a12}<-RelTableStrComp1;...;{p1n,a1n}<-RelTableStrComp1;
p11=p12;p12=p13;...;p1i=p1n;...;P]
3. This step removes self-Key-Join generators: all generators are inserted into an ArrayList, genList, and for each element in
the list, if there is a self-Key-Join gen within it, remove the selfKeyJoin gen
4. Method replaceVarValWithMap replaces vars in h and P with their values from varMap, which is the hashMap between the main
comp vars and the vars in sub RelTableStrComp:
5. This step creates a new comp which consists of the remaining generators in the genList and unnests nested generators by
replacing the current generator with the generator in its sub RelTableStrComp
- Author:
- Hao Fan, Lucas Zamboulis
|
Field Summary |
protected java.util.logging.Logger |
logger
|
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
logger
protected java.util.logging.Logger logger
RelationSKJEliminator
public RelationSKJEliminator()
optimise
public boolean optimise(ASG g)