edu.wpi.cs.dsrg.xmldb.xat.component.xattreegeneration
Class QueryDecorrelation

java.lang.Object
  |
  +--edu.wpi.cs.dsrg.xmldb.xat.common.visitorpattern.InheritableVisitor
        |
        +--edu.wpi.cs.dsrg.xmldb.xat.component.xattreegeneration.QueryDecorrelation

public class QueryDecorrelation
extends InheritableVisitor

This class visits the XAT Tree constructed in ParserTraverse and get rid of For operaters. Thus we can get rid of inner loops in the XAT Tree and make a flat algebra tree.

To understand this code, one should know how the decorrelation works and what our algorithm is. It would also be helpful to know what a visitor pattern is because that is what we use to traverse through the query.

Currently, we need to 2 round of decorrelation to get rid of all For loops.

The Main issues in decorrelation is: 1. empty collection problem 2. count bugs.

Since:
1.0
See Also:
edu.wpi.cs.dsrg.xmldb.xat.common.visitorpattern

Field Summary
protected  OperatorBuilder builder
          used to create operators
protected  java.lang.String[] contextForBindings
          record the context FOR bindings for the groupby operator generation.
protected  XATNode currentParent
          A global point to denote where is the current parent we are working with.
protected  XATTree decorrTree
          record the decorrelated XAT Tree.
 
Constructor Summary
protected QueryDecorrelation()
          Class Default Constructor
protected QueryDecorrelation(java.lang.String[] forContext, XATTree tree)
          Class Constructor with outer For binding context
  QueryDecorrelation(XATTree tree)
          Class Constructor with XAT Tree to be decorrelated.
 
Method Summary
 java.lang.Object dispatch()
          To visit a null object.
 java.lang.Object dispatch(java.lang.Object obj)
          Called when an object hasn't been implemented by the visitor pattern default handling of the unknow operators.
 XATTree getDecorTree()
          Access method of field decorrelate tree.
 boolean isDebug()
          Get the value of the propertity 'DEBUG_QueryDecorrelation'.
protected  void moveLOJ(XATOperator xOp)
          Find and move LOJ below specific node.
 java.lang.Object visit(Aggregate aggregate)
          for the aggregate function there will be a groupby operator created with the FOR context, and then put the aggregate function as the subtree of it.
 java.lang.Object visit(Delete delNode)
          Dummy function for delete operator
 java.lang.Object visit(Expose expNode)
          Dummy function for expose operator
 java.lang.Object visit(FOR forOp)
          When a FOR node is encountered, save its child as a temporary node.
 java.lang.Object visit(Function function)
          Called when an aggregate function exists in the tree.
 java.lang.Object visit(GroupBy groupby)
          for the groupby there will be a groupby operator created with the FOR context, and then put the original groupby as the subtree of it.
 java.lang.Object visit(Insert insNode)
          Dummy function for insert operator
 java.lang.Object visit(Intersection intersect)
          Dummy function for intersect operator
 java.lang.Object visit(NameColumn renNode)
          Dummy function for Rename operator
 java.lang.Object visit(NavCollection navNode)
          Dummy function for navigate collection operator
 java.lang.Object visit(NavUnnest navNode)
          Dummy function for navigate unnest operator
 java.lang.Object visit(OrderBy orderBy)
          Dummy function for orderby operator
 java.lang.Object visit(Replace repNode)
          Dummy function for replace operator
 java.lang.Object visit(Select selectNode)
          Dummy function for select operator
 java.lang.Object visit(Source sourceOp)
          Inserts a source node into the newly decorrelated tree.
 java.lang.Object visit(Tagger taggerNode)
          Dummy function for tagger operator
 java.lang.Object visit(Union union)
          Dummy function for union operator
 
Methods inherited from class edu.wpi.cs.dsrg.xmldb.xat.common.visitorpattern.InheritableVisitor
getAncestors, getMethod, visit, visit
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

contextForBindings

protected java.lang.String[] contextForBindings
record the context FOR bindings for the groupby operator generation.
Since:
1.0

decorrTree

protected XATTree decorrTree
record the decorrelated XAT Tree.
Since:
1.0

currentParent

protected XATNode currentParent
A global point to denote where is the current parent we are working with.
Since:
1.0

builder

protected OperatorBuilder builder
used to create operators
Since:
1.0
Constructor Detail

QueryDecorrelation

protected QueryDecorrelation()
Class Default Constructor
Since:
1.0

QueryDecorrelation

protected QueryDecorrelation(java.lang.String[] forContext,
                             XATTree tree)
Class Constructor with outer For binding context
Since:
1.0

QueryDecorrelation

public QueryDecorrelation(XATTree tree)
Class Constructor with XAT Tree to be decorrelated.
Since:
1.0
Method Detail

dispatch

public java.lang.Object dispatch()
Description copied from class: InheritableVisitor
To visit a null object.
Overrides:
dispatch in class InheritableVisitor

dispatch

public java.lang.Object dispatch(java.lang.Object obj)
Called when an object hasn't been implemented by the visitor pattern default handling of the unknow operators.
Overrides:
dispatch in class InheritableVisitor

getDecorTree

public XATTree getDecorTree()
Access method of field decorrelate tree.
Returns:
XATTree
Since:
1.0

isDebug

public boolean isDebug()
Get the value of the propertity 'DEBUG_QueryDecorrelation'.
Returns:
boolean True: With debug information. False: No debug information.
Since:
1.0

moveLOJ

protected void moveLOJ(XATOperator xOp)
Find and move LOJ below specific node.
Parameters:
xOp - edu.wpi.cs.dsrg.xmldb.xat.common.operator.XATOperator
Since:
1.0

visit

public java.lang.Object visit(Expose expNode)
Dummy function for expose operator
Parameters:
expNode - edu.wpi.cs.dsrg.xmldb.xat.common.operator.specialoperator.ExposeImp
Returns:
java.lang.Object
Since:
1.0

visit

public java.lang.Object visit(FOR forOp)
When a FOR node is encountered, save its child as a temporary node. This will be the root of a mini-tree. Then, visit the FOR node's subtree, and look for subsequent values of FOR nodes. If more than one FOR node exits, a Cartesian product must be created. If only one FOR node exists, the mini-tree and the FOR node's subtree can be directly combined.
Parameters:
forOp - FOR operator
Returns:
java.lang.Object
Since:
1.0

visit

public java.lang.Object visit(Function function)
Called when an aggregate function exists in the tree. A GroupBy node replaces the Function node, and an OuterJoin node replaces the FOR node. A Distinct node is created underneath the OuterJoin node. The two children of the OuterJoin are the Distinct node and the root of the subtree.
Parameters:
function - edu.wpi.cs.dsrg.xmldb.xat.common.operator.specialoperator.function.FunctionImp
Returns:
java.lang.Object
Since:
1.0

visit

public java.lang.Object visit(NameColumn renNode)
Dummy function for Rename operator
Parameters:
renNode - edu.wpi.cs.dsrg.xmldb.xat.common.operator.updateoperator.RenameImp
Returns:
java.lang.Object
Since:
1.0

visit

public java.lang.Object visit(Source sourceOp)
Inserts a source node into the newly decorrelated tree. If there are two source nodes, then a Cartesian Product node is created.
Parameters:
sourceNode - edu.wpi.cs.dsrg.xmldb.xat.common.operator.specialoperator.SourceImp
Returns:
java.lang.Object
Since:
1.0

visit

public java.lang.Object visit(GroupBy groupby)
for the groupby there will be a groupby operator created with the FOR context, and then put the original groupby as the subtree of it. in terms of the decorrelated tree, the old groupby node will be deleted from its parent. and then the new groupby will take its position.
Parameters:
groupby - edu.wpi.cs.dsrg.xmldb.xat.common.operator.sqloperator.GroupByImp
Returns:
java.lang.Object
Since:
1.0

visit

public java.lang.Object visit(Intersection intersect)
Dummy function for intersect operator
Parameters:
intersect - edu.wpi.cs.dsrg.xmldb.xat.common.operator.sqloperator.IntersectImp
Returns:
java.lang.Object
Since:
1.0

visit

public java.lang.Object visit(OrderBy orderBy)
Dummy function for orderby operator
Parameters:
orderBy - edu.wpi.cs.dsrg.xmldb.xat.common.operator.sqloperator.OrderByImp
Returns:
java.lang.Object
Since:
1.0

visit

public java.lang.Object visit(Select selectNode)
Dummy function for select operator
Parameters:
selectNode - edu.wpi.cs.dsrg.xmldb.xat.common.operator.sqloperator.SelectImp
Returns:
java.lang.Object
Since:
1.0

visit

public java.lang.Object visit(Union union)
Dummy function for union operator
Parameters:
union - edu.wpi.cs.dsrg.xmldb.xat.common.operator.sqloperator.UnionImp
Returns:
java.lang.Object
Since:
1.0

visit

public java.lang.Object visit(Delete delNode)
Dummy function for delete operator
Parameters:
delNode - edu.wpi.cs.dsrg.xmldb.xat.common.operator.updateoperator.DeleteImp
Returns:
java.lang.Object
Since:
1.0

visit

public java.lang.Object visit(Insert insNode)
Dummy function for insert operator
Parameters:
insNode - edu.wpi.cs.dsrg.xmldb.xat.common.operator.updateoperator.InsertImp
Returns:
java.lang.Object
Since:
1.0

visit

public java.lang.Object visit(Replace repNode)
Dummy function for replace operator
Parameters:
repNode - edu.wpi.cs.dsrg.xmldb.xat.common.operator.updateoperator.ReplaceImp
Returns:
java.lang.Object
Since:
1.0

visit

public java.lang.Object visit(Aggregate aggregate)
for the aggregate function there will be a groupby operator created with the FOR context, and then put the aggregate function as the subtree of it. In terms of the decorrelated tree, the aggregate node will be deleted from its parent. and then the groupby will take its position.
Parameters:
aggregate - edu.wpi.cs.dsrg.xmldb.xat.common.operator.xmloperator.AggregateImp
Returns:
java.lang.Object
Since:
1.0

visit

public java.lang.Object visit(NavCollection navNode)
Dummy function for navigate collection operator
Parameters:
navNode - edu.wpi.cs.dsrg.xmldb.xat.common.operator.xmloperator.NavCollectionImp
Returns:
java.lang.Object
Since:
1.0

visit

public java.lang.Object visit(NavUnnest navNode)
Dummy function for navigate unnest operator
Parameters:
navNode - edu.wpi.cs.dsrg.xmldb.xat.common.operator.xmloperator.NavUnnestImp
Returns:
java.lang.Object
Since:
1.0

visit

public java.lang.Object visit(Tagger taggerNode)
Dummy function for tagger operator
Parameters:
taggerNode - edu.wpi.cs.dsrg.xmldb.xat.common.operator.xmloperator.TaggerImp
Returns:
java.lang.Object
Since:
1.0