|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--edu.wpi.cs.dsrg.xmldb.xat.common.visitorpattern.InheritableVisitor | +--edu.wpi.cs.dsrg.xmldb.xat.common.visitorpattern.TwoParamVisitor | +--edu.wpi.cs.dsrg.xmldb.xat.component.xatrewrite.ReWriteRules
This class is the super class for all equivalence rule classes.
An object of this class is created with a Vector of Strings containing the order of classes to look at when trying to find a rule for 2 operators. Calls are then made to evaluateRules with 2 nodes that the user wishes to evalute. The TwoParamVisitor class from the visitorpattern package is used to determine the correct equivalence rule to use for a given pair of XATOperators. This is done by iterating over the classes provided in the classVector and calling the visit(Object, Object) method of each class. If a rule is not found in a class, the next class is looked at. If no rules are found for a given pair, an ReWriteRulesNoRulesFound exception is thrown. Equivalence rules are defined in subclasses named after the parent operator. ReWriteNavigationRules defines the equivalence rules for Navigate Operators. ReWriteOrderByRules defines the equivalence rules for OrderBy Operators and so on. A rule is a method in the strucure of visit(XATOperator parent, XATOperator child). The rule for swapping a Navigate with a Source is defined in ReWriteNavigationRules.visit(Navigate, Source). Each rule will perform modififactions neccessary for the swap of the two operators if such a swap is possible. If the nodes can be swapped, the rule will do so. See each rule for the logic behind that rule. Each rule returns a ReWriteResult object. This object will tell the calling program if the Operators were be swapped, is the parent in its final position, and should either node be deleted.
ReWriteResult
Field Summary | |
protected java.util.Vector |
classVector
Vector that contains the list and order of rule classes to look at. |
protected ReWriteResult |
result
ReWriteResult that describes the results from performing the Equivalence Rule |
protected static java.util.Hashtable |
statis
Hashtable to keep the rule statistics of this rewrite rules In the format of "method obj, Integer count". |
protected BindingTable |
variableTable
BindingTable that is used to store the variables and the associated columnPaths |
Constructor Summary | |
ReWriteRules()
Default ReWriteRules constructor. |
|
ReWriteRules(java.util.Vector sourceList)
ReWriteRules constructor. |
|
ReWriteRules(java.util.Vector sourceList,
BindingTable varList)
Constructor that accepts a Vector sourceList that is set to classVector and a Hashtable that is set to variableTable. |
Method Summary | |
protected NavigationStep[] |
combineSteps(NavigationStep[] entryPoint,
NavigationStep[] destination)
This method puts the entryPoint and destination step arrays of a Navigate Operator into 1 bigger array to make it easier to manipulate. |
protected boolean |
copyNode(XATNode parent,
XATNode child)
Replacing the child node with parent node. |
java.lang.String |
createString(NavigationStep[] step)
Convert an array of NavigationStep into String. |
boolean |
deleteAggregate(XATNode param)
Decide if an given Aggregate operator can be deleted or not. |
boolean |
deletePartialTagger(DOMPatternNode rootNode)
Deprecated. |
boolean |
deleteWholeTagger(DOMPatternNode rootNode)
Deprecated. |
java.lang.Object |
dispatch()
To visit a null object. |
java.lang.Object |
dispatch(java.lang.Object object)
To visit any object. |
java.lang.Object |
dispatch(java.lang.Object object1,
java.lang.Object object2)
To visit two objects. |
ReWriteResult |
evaluateRules(XATNode parent)
Evaluate the rules over 2 XATOperators. |
ReWriteResult |
evaluateRules(XATNode parent,
XATNode child)
Evaluate the rules over 2 XATOperators. |
protected boolean |
findMatchingNavigationNode(java.lang.String binding,
XATNode root)
An alternate definition for findMatchingNavigationNode. |
protected boolean |
findMatchingNavigationNode(VarStep entryPoint,
XATNode root)
Find a Navigate operator whose binding matches the entryPoint array. |
protected void |
getChildren(java.util.Vector destinationVector,
XATNode root)
Get all children of a given root node. |
protected void |
getColumnNames(BinExpression exp,
java.util.Vector columnNames)
Iterates over the BinExpression in order to find all of the column Names anytime a column name is found, it is added into the Vector. |
static java.util.Hashtable |
getStatis()
Return the statistics of the rewrite rules. |
BindingTable |
getVariableTable()
Insert the method's description here. |
protected boolean |
isDebug()
Get the value of the propertity 'DEBUG_NavTaggerCancelout'. |
protected boolean |
isGatherStatistics()
A flag to check whether to get the statistics from rewrite rules. |
protected boolean |
isUsedAbove(XATNode startingPoint,
java.lang.String columnToFind)
traverse up the tree, starting from the startingPoint parameter, checking if columnToFind is used in any entry point in a Navigate, parameter in a Select, or column in a Tagger. |
protected void |
moveNode(XATNode parent,
XATNode child)
MoveNode will alter the XATTree structue by moving the parent node directly under the child. |
protected void |
moveNodeToRoot(XATNode root,
XATNode nodeToMove)
MoveNodeToRoot will alter the XATTree structue by moving the node to the root. |
void |
setDebug(boolean newDebug)
Insert the method's description here. |
void |
setVariableTable(BindingTable newVariableTable)
Insert the method's description here. |
protected void |
swap(XATOperator operator1,
XATOperator operator2)
Swaps the operators of 2 nodes. |
java.lang.Object |
visit(java.lang.Object object)
If there is an inheretance between the visited objects, it will only match the highest class. |
java.lang.Object |
visit(java.lang.Object obj1,
java.lang.Object obj2)
We add funtionality to print out the rules used in this rewrite. |
Methods inherited from class edu.wpi.cs.dsrg.xmldb.xat.common.visitorpattern.TwoParamVisitor |
getMethod,
visit |
Methods inherited from class edu.wpi.cs.dsrg.xmldb.xat.common.visitorpattern.InheritableVisitor |
getAncestors,
getMethod,
visit |
Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
Field Detail |
protected ReWriteResult result
protected java.util.Vector classVector
protected BindingTable variableTable
protected static java.util.Hashtable statis
Constructor Detail |
public ReWriteRules()
public ReWriteRules(java.util.Vector sourceList)
sourceList
- The list of operator types being considered to apply this rewrite rule.BindingTable
public ReWriteRules(java.util.Vector sourceList, BindingTable varList)
sourceList
- The list of operator types being considered to apply this rewrite rule.BindingTable
- The binding table of given XAT.BindingTable
Method Detail |
protected NavigationStep[] combineSteps(NavigationStep[] entryPoint, NavigationStep[] destination)
entryPoint
- The entry point of Navigate operator.destination
- The destination of Navigate operator.NavigationStep
protected boolean copyNode(XATNode parent, XATNode child)
This method will alter the XATTree structue by copying the parent node directly replace child. The child's children will be altered to point to parent. This is primarily used to copy a node under the correct Join / Union branch. Structure of tree parent = x2, child = x4 old structure x1 -> x2 ---> x3 -> x4 new structure x1 -> x2 ---> x3 -> Clone of x2 -> x4
parent
- The parent node.child
- The child node.swap
public java.lang.String createString(NavigationStep[] step)
step
- NavigationStep from which to create a string.NavigationStep
public boolean deleteAggregate(XATNode param)
param
- The node of Aggregrate operator.Tagger
,
Aggregate
public boolean deletePartialTagger(DOMPatternNode rootNode)
rootNode
- The root of the DOMPattern to start iterating over.Tagger
,
DOMPatternNode
,
RootNodeImp
public boolean deleteWholeTagger(DOMPatternNode rootNode)
rootNode
- The root of the DOMPattern to start iterating over.Tagger
,
RootNodeImp
,
DOMPatternNode
public java.lang.Object dispatch()
public java.lang.Object dispatch(java.lang.Object object)
public java.lang.Object dispatch(java.lang.Object object1, java.lang.Object object2)
public ReWriteResult evaluateRules(XATNode parent) throws ReWriteRulesNoRulesFound
parent
- The parent node that we will try to find a rule for.ReWriteResult
public ReWriteResult evaluateRules(XATNode parent, XATNode child) throws ReWriteRulesNoRulesFound
parent
- The parent node that we will try to find a rule for.child
- The child node that we will try to find a rule for.ReWriteResult
protected boolean findMatchingNavigationNode(VarStep entryPoint, XATNode root)
entryPoint
- The EntryPoint to match.root
- The root node to start looking at.VarStep
protected boolean findMatchingNavigationNode(java.lang.String binding, XATNode root)
binding
- The binding of a Navigate operator to the match.root
- The root node to start looking at.VarStepImp
,
findMatchingNavigationNode
protected void getChildren(java.util.Vector destinationVector, XATNode root)
destinationVector
- The vector to hold all children nodes.root
- The root XATNode to get the children from.XATNode
protected void getColumnNames(BinExpression exp, java.util.Vector columnNames)
exp
- Expressionpublic static java.util.Hashtable getStatis()
public BindingTable getVariableTable()
protected boolean isDebug()
protected boolean isGatherStatistics()
protected boolean isUsedAbove(XATNode startingPoint, java.lang.String columnToFind)
column
- java.lang.Stringprotected void moveNode(XATNode parent, XATNode child)
MoveNode will alter the XATTree structue by moving the parent node directly under the child. The child's children will be altered to point to parent. This is primarily used to move a node under the correct Join / Union branch. Structure of tree parent = x2, child = x4 old structure x1 -> x2 -> x3 -> x4 new structure x1 -> x3 -> x2 -> x4 Any other time you want to switch the positions of 2 nodes, swap(XATOperator, XATOperator) should be used.
parent
- child
- swap
protected void moveNodeToRoot(XATNode root, XATNode nodeToMove)
MoveNodeToRoot will alter the XATTree structue by moving the node to the root. This is to be used in conjunction with rename push down. Renames will be put as the new root, then pushed down and each node it goes through will be changed. Structure of tree root = x1, node = x4 old structure x1 -> ... -> x3 -> x4 -> x5 new structure x4 -> x1 -> ... x3 -> x5
root
- nodeToMove
- rename
public void setDebug(boolean newDebug)
newDebug
- booleanpublic void setVariableTable(BindingTable newVariableTable)
newVariableTable
- java.util.BindingTableprotected void swap(XATOperator operator1, XATOperator operator2)
operator1
- operator2
- public java.lang.Object visit(java.lang.Object object)
object
- public java.lang.Object visit(java.lang.Object obj1, java.lang.Object obj2)
obj1
- The first object.obj2
- The second object.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |