|
|||||||||
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.operator.XATPropertiesImp | +--edu.wpi.cs.dsrg.xmldb.xat.common.operator.XATQueryObjectImp | +--edu.wpi.cs.dsrg.xmldb.xat.component.xatrewrite.ReWriteTraversal
ReWriteTraversal is the traversal strategy used in the rewrite steps It is responsible for iterating over an XAT algebra tree and finding 2 nodes to evaluate equivalence rules on. The class is instantiated by passing in an XATTree to traverse, a ReWriteRules object that will be used to evaluate the rules and a Vector containing names (strings) of XATOperators (fully quantified) to rewrite. doPushDown is then called with a direction to rewrite rules. The types of XATOperators to evaluate are determined before starting the traversal. A Vector is passed into the constructor This reWriteOrder vector also determines the order of operators to evaluate. The traversal starts by iterating over the tree and finding all Source operators. Then, starting with the first operator, travels up the tree until the first XATOperator (x1) whose type corresponds to the first class name in the reWriteOrder Vector is found. Operators who are in their final position are not used. Next,depending on the direction the user wishes to rewrite rules, the system will either take the parent or child of x1. A call is then made to ReWriteRules.evaluateRules passing in the 2 operators. Once the rule is evaluted for 2 nodes, the ReWriteResult object is interpreted and If the operator is in its finalPosition (from the result object), the hashtable that keeps track of which operators have completed evaluation is updated and the next Operator is found. If the operator is not in its final position, the new child or parent (depending on direction) is used to evalute another rule. The process continues until all operators are in their final position.
ReWriteResult
,
XATNode
,
XATOperator
,
XATTree
, Serialized FormField Summary | |
static int |
DOWN
Constant to rewrite rules downward. |
protected java.util.Hashtable |
reWriteList
The HashTabe stores the list of operators in the tree and whether they are in their final position or not. |
protected java.util.Vector |
reWriteOrder
List of Strings representing the order and name of XATOperators to rewrite. |
protected XATTree |
reWriteTree
The XATTree to rewrite |
protected ReWriteRules |
rules
Contains the equivalence rules |
protected boolean |
stepThrough
Out put the tree after each rewrtie step or not. |
protected java.util.Vector |
stepTrees
The tree in current rewrite step. |
static int |
UP
Constant to rewrite rules upward. |
Fields inherited from class edu.wpi.cs.dsrg.xmldb.xat.common.operator.XATQueryObjectImp |
stats,
statsPresent |
Constructor Summary | |
ReWriteTraversal(XATTree tree,
ReWriteRules p1,
java.util.Vector order)
ReWriteTraversal constructor. |
|
ReWriteTraversal(XATTree tree,
ReWriteRules p1,
java.util.Vector order,
boolean step)
ReWriteTraversal constructor. |
Method Summary | |
XATTree |
doPushdown(int direction)
This method uses the XATtree passed into the constructor, and traverses over the tree and finds 2 nodes to try to swap. |
XATTree |
doRewrite(int direction)
This method repeatly call doPushdown until there is no more changes in the Pushdown. |
protected XATNode |
findNextNode(XATNode paramNode,
java.lang.String toMatch)
Accepts an XATNode paramNode and an XATOperator. |
protected XATNode |
findNextNode(XATTree tree,
XATNode paramNode,
java.lang.String toMatch)
Find next node need to be pushed down. |
protected void |
getAllSourceNodes(java.util.Vector sourceSet,
XATNode root,
XATTree tree)
Find all of the Source operators in an XATTree. |
protected void |
getChildren(java.util.Vector destinationVector,
XATNode root)
getChildren accepts a destination Vector and an XATNode it then puts all of the root's children into this vector |
java.util.Vector |
getStepTrees()
Get the tree in current rewrite step. |
boolean |
isDebug()
Get the value of the propertity 'DEBUG_ReWriteTraversal'. |
boolean |
isIsChanged()
Get the value of the propertity 'isChanged'. |
protected boolean |
isPushedDown(XATOperator toCheck)
Check if an operator need any push down or not. |
boolean |
isStepThrough()
Get the value of the propertity 'StepThrough'. |
void |
setDebug(boolean newDebug)
I temporarily keep this method. |
protected void |
setDefaultProperties()
This method will be called by the constructor. |
void |
setIsChanged(boolean newIsChanged)
Get the value of the propertity 'isChanged'. |
protected void |
setPushedDown(XATOperator toSet,
boolean val)
Modifies this operators value in the reWriteList according to the val parameter. |
void |
setStepTrees(java.util.Vector newStepTrees)
Get the tree in current rewrite step. |
Methods inherited from class edu.wpi.cs.dsrg.xmldb.xat.common.operator.XATQueryObjectImp |
addStatistic,
compareTo,
getStatistics,
isValidStatistic,
setDefaultStatistics |
Methods inherited from class edu.wpi.cs.dsrg.xmldb.xat.common.operator.XATPropertiesImp |
addProperty,
getProperties,
getProperty,
isValidPropertyName,
setNewPropertyValue,
setProperty |
Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
Field Detail |
protected XATTree reWriteTree
protected java.util.Hashtable reWriteList
The HashTabe stores the list of operators in the tree and whether they are in their final position or not. The key is the operator, the value is a Boolean that represents whether the operator is in its final position.
protected ReWriteRules rules
protected java.util.Vector reWriteOrder
public static final int DOWN
public static final int UP
protected boolean stepThrough
protected java.util.Vector stepTrees
Constructor Detail |
public ReWriteTraversal(XATTree tree, ReWriteRules p1, java.util.Vector order)
tree
- The tree to rewrite.p1
- The class contains equivalance rules.order
- The vector contains strings of the types of operators to optimize.ReWriteRules
,
XATTree
public ReWriteTraversal(XATTree tree, ReWriteRules p1, java.util.Vector order, boolean step)
tree
- The tree to rewrite.p1
- The class contains equivalance rules.order
- The vector contains strings of the types of operators to optimize.step
- Identify if the ShowTreeCheckBox is selected or not.ReWriteRules
,
XATTree
Method Detail |
public XATTree doPushdown(int direction)
This method uses the XATtree passed into the constructor, and traverses over the tree and finds 2 nodes to try to swap. The types and order of operators to pushDown are defined in the constructor.
direction
- The direction to push nodes.XATTree
,
ReWriteResult
,
XATOperator
public XATTree doRewrite(int direction)
direction
- The direction of rewrite.XATTree
protected XATNode findNextNode(XATTree tree, XATNode paramNode, java.lang.String toMatch)
This method will traverse the tree, starting from paramNode and ending as it finds a node of type that has not been pushedDown. This node is then returned. If no such node is found, it returns null.
paramNode
- The node to start looking from.toMatch
- The type of operator to match.XATNode
protected XATNode findNextNode(XATNode paramNode, java.lang.String toMatch)
Accepts an XATNode paramNode and an XATOperator. The tree is traversed starting at paramNode and ends when it finds a node of type type that has not been pushedDown. This node is then returned If no such node is found, it returns null
paramNode
- The node to start looking from.toMatch
- The type of operator to match.XATNode
protected void getAllSourceNodes(java.util.Vector sourceSet, XATNode root, XATTree tree)
This method first look at all of the root's children and adds them to the vector if that nodes' operator is an XML source . The function is then recurvsively called on each of root's children until there are no more nodes to look at.
sourceSet
- stores all of the Source operators foundroot
- The root of a tree to iterate overXATTree
,
XATNode
protected void getChildren(java.util.Vector destinationVector, XATNode root)
destinationVector
- root
- XATNode
public java.util.Vector getStepTrees()
public boolean isDebug()
public boolean isIsChanged()
protected boolean isPushedDown(XATOperator toCheck)
If the operator does not appear in the list, the operator is added and the value is set to false
toCheck
- The XATOperator to look up in the reWriteList.XATOperator
public boolean isStepThrough()
public void setDebug(boolean newDebug)
newDebug
- booleanprotected void setDefaultProperties()
public void setIsChanged(boolean newIsChanged)
newIsChanged
- True: The tree is changed. False: otherwise.protected void setPushedDown(XATOperator toSet, boolean val)
toSet
- The XATOperator to set final position.val
- True: if the operator is now in its final position. False: otherwise.public void setStepTrees(java.util.Vector newStepTrees)
newStepTrees
- java.util.Vector
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |