edu.wpi.cs.dsrg.xmldb.xat.component.xatrewrite
Class MergeOperatorRules

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
                    |
                    +--edu.wpi.cs.dsrg.xmldb.xat.component.xatrewrite.MergeOperatorRules

public class MergeOperatorRules
extends ReWriteRules

This Class is used to merge operators by traversing the XAT.

Since:
1.0

Fields inherited from class edu.wpi.cs.dsrg.xmldb.xat.component.xatrewrite.ReWriteRules
classVector, result, statis, variableTable
 
Constructor Summary
MergeOperatorRules()
          Default MergeOperatorRules constructor.
 
Method Summary
protected  void findMergable(Tagger parent, Tagger child, DOMPatternNode pPatternNode, java.util.Vector mergable)
          Find if the two taggers are mergable or not.
protected  ReWriteResult mergeNavigates(Navigate parent, Navigate child)
          Merges two Navigates
protected  int mergeTaggers(Tagger parent, Tagger child)
          Merge two Taggers if possible.
protected  void reduceGroupBy(GroupBy parent)
          Rule to merge GroupBy with GroupBy
protected  java.lang.Object reduceGroupByNavigate(GroupBy gbOp, Navigate navOp)
          It used to merge a GB with Agg() on top of NavUnnest/NavCollection into NavCollection.
protected  void splitSelect(Select parent)
          Recursively splits a Select operator.
 java.lang.Object visit(Distinct parent, Distinct child)
          Rule to merge Distinct with Distinct
 java.lang.Object visit(Distinct parent, XATOperator child)
          Rule to merge Distinct with XATOperator
 java.lang.Object visit(GroupBy gbOp, XATOperator child)
          Rule to merge GroupBy with XATOperator
 java.lang.Object visit(NavCollection parent, NavCollection child)
          Rule to merge NavCollection with NavCollection.
 java.lang.Object visit(NavCollection parent, NavUnnest child)
          Rule to merge NavCollection with NavUnnest These two cannot be merged
 java.lang.Object visit(NavUnnest navOp, GroupBy gbOp)
          Merge NavigateUnnest and a GroupBy together, and make a rename operator out of it.
 java.lang.Object visit(NavUnnest parent, NavCollection child)
          Rule to merge NavUnnest with NavCollection
 java.lang.Object visit(NavUnnest parent, NavUnnest child)
          Rule to merge NavUnnest with NavUnnest
 java.lang.Object visit(Select parent, XATOperator child)
          This is the rule to split a Select in half The Select can be split in half iff it contains an AND or OR If the Select contains an AND then the a new Select is created and the tree looks like this: Before: Select (exp1 AND exp2) After: Select (exp1) | Select (exp2) If the Select contains an OR then we dont support it yet....
 java.lang.Object visit(Tagger parent, Merge child)
          Rule to merge Tagger with Merge.
 java.lang.Object visit(Tagger parent, Tagger child)
          Rule to merge Tagger with Tagger
 
Methods inherited from class edu.wpi.cs.dsrg.xmldb.xat.component.xatrewrite.ReWriteRules
combineSteps, copyNode, createString, deleteAggregate, deletePartialTagger, deleteWholeTagger, dispatch, dispatch, dispatch, evaluateRules, evaluateRules, findMatchingNavigationNode, findMatchingNavigationNode, getChildren, getColumnNames, getStatis, getVariableTable, isDebug, isGatherStatistics, isUsedAbove, moveNode, moveNodeToRoot, setDebug, setVariableTable, swap, visit, visit
 
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
 

Constructor Detail

MergeOperatorRules

public MergeOperatorRules()
Default MergeOperatorRules constructor. Constructs a MergeOperatorRules object.
Since:
1.0
Method Detail

findMergable

protected void findMergable(Tagger parent,
                            Tagger child,
                            DOMPatternNode pPatternNode,
                            java.util.Vector mergable)
Find if the two taggers are mergable or not.
Parameters:
parent - The parent Tagger node.
child - The child Tagger node.
pPatternNode - The DOMPatternNode of parent Tagger.
mergable - The Vector of mergable element.
Returns:
void
Since:
1.0
See Also:
DOMPatternNode, Tagger

mergeNavigates

protected ReWriteResult mergeNavigates(Navigate parent,
                                       Navigate child)
Merges two Navigates
Parameters:
parent - The parent Navigate node.
child - The child Navigate node.
Returns:
ReWriteResult. The swap flag in ReWriteResult true if the nodes were swapped, false otherwise.
Since:
1.0
See Also:
Navigate

mergeTaggers

protected int mergeTaggers(Tagger parent,
                           Tagger child)
Merge two Taggers if possible.
Parameters:
parent - The parent Tagger node.
child - The child Tagger node.
Returns:
int The size of the mergable node in Tagger Pattern.
Since:
1.0
See Also:
Tagger, findMergable

reduceGroupBy

protected void reduceGroupBy(GroupBy parent)
Rule to merge GroupBy with GroupBy
Parameters:
parent - The parent GroupBy node.
Returns:
void
Since:
1.0
See Also:
GroupBy

reduceGroupByNavigate

protected java.lang.Object reduceGroupByNavigate(GroupBy gbOp,
                                                 Navigate navOp)
It used to merge a GB with Agg() on top of NavUnnest/NavCollection into NavCollection. If the GB has Agg() as function, and the GB's context is same as NavUnnest/NavCollection entry.
Parameters:
gbOp - The GroupBy operator.
unnestOp - The NavUnnest operator.
Returns:
ReWriteResult. The swap flag in ReWriteResult true if the nodes were swapped, false otherwise.
Since:
1.0
See Also:
GroupBy, Navigate

splitSelect

protected void splitSelect(Select parent)
Recursively splits a Select operator.
Parameters:
parent - The Select operaotr.
Returns:
void
Since:
1.0
See Also:
Select

visit

public java.lang.Object visit(Distinct parent,
                              Distinct child)
Rule to merge Distinct with Distinct
Parameters:
parent - The parent Distinct operator.
child - The child Distinct operator.
Returns:
ReWriteResult. The swap flag in ReWriteResult true if the nodes were swapped, false otherwise.
Since:
1.0
See Also:
Distinct

visit

public java.lang.Object visit(Distinct parent,
                              XATOperator child)
Rule to merge Distinct with XATOperator
Parameters:
parent - The parent Distinct operator.
child - The child XATOperator operator.
Returns:
ReWriteResult. The swap flag in ReWriteResult true if the nodes were swapped, false otherwise.
Since:
1.0
See Also:
Distinct, XATOperator

visit

public java.lang.Object visit(GroupBy gbOp,
                              XATOperator child)
Rule to merge GroupBy with XATOperator
Parameters:
gbOp - The parent GroupBy operator.
child - The child XATOperator operator.
Returns:
ReWriteResult. The swap flag in ReWriteResult true if the nodes were swapped, false otherwise.
Since:
1.0
See Also:
GroupBy, XATOperator

visit

public java.lang.Object visit(Select parent,
                              XATOperator child)
This is the rule to split a Select in half The Select can be split in half iff it contains an AND or OR If the Select contains an AND then the a new Select is created and the tree looks like this: Before: Select (exp1 AND exp2) After: Select (exp1) | Select (exp2) If the Select contains an OR then we dont support it yet.... Of course the Select can contain an arbitray amount of AND / OR operators so we have deal with that accordingly
Parameters:
parent - The parent Select operator.
child - The child XATOperator operator.
Returns:
ReWriteResult. The swap flag in ReWriteResult true if the nodes were swapped, false otherwise.
Since:
1.0
See Also:
Select

visit

public java.lang.Object visit(NavCollection parent,
                              NavCollection child)
Rule to merge NavCollection with NavCollection. If the child's output column matches the parents entry point, then the two operators can be merged into one larger NavUnnest iff the output of the child is not referenced anywhere else
Parameters:
parent - The parent NavCollection operator.
child - The child NavCollection operator.
Returns:
ReWriteResult. The swap flag in ReWriteResult true if the nodes were swapped, false otherwise.
Since:
1.0
See Also:
NavCollection

visit

public java.lang.Object visit(NavCollection parent,
                              NavUnnest child)
Rule to merge NavCollection with NavUnnest These two cannot be merged
Parameters:
parent - The parent NavCollection operator.
child - The child NavUnnest operator.
Returns:
ReWriteResult. The swap flag in ReWriteResult true if the nodes were swapped, false otherwise.
Since:
1.0
See Also:
NavCollection, NavUnnest

visit

public java.lang.Object visit(NavUnnest navOp,
                              GroupBy gbOp)
Merge NavigateUnnest and a GroupBy together, and make a rename operator out of it. If will check following conditions: . Unnest entry = Groupby's output column. . Groupby only got an aggregate as its function. Then the rename will be from "gb output" to "unnest binding".
Parameters:
navOp - The parent NavUnnest operator.
gbOp - The child GroupBy operator.
Returns:
ReWriteResult. The swap flag in ReWriteResult true if the nodes were swapped, false otherwise.
Since:
1.0
See Also:
GroupBy, NavUnnest

visit

public java.lang.Object visit(NavUnnest parent,
                              NavCollection child)
Rule to merge NavUnnest with NavCollection
Parameters:
parent - The parent NavUnnest operator.
child - The child NavCollection operator.
Returns:
ReWriteResult. The swap flag in ReWriteResult true if the nodes were swapped, false otherwise.
Since:
1.0
See Also:
NavCollection, NavUnnest

visit

public java.lang.Object visit(NavUnnest parent,
                              NavUnnest child)
Rule to merge NavUnnest with NavUnnest
Parameters:
parent - The parent NavUnnest operator.
child - The child NavUnnest operator.
Returns:
ReWriteResult. The swap flag in ReWriteResult true if the nodes were swapped, false otherwise.
Since:
1.0
See Also:
NavUnnest

visit

public java.lang.Object visit(Tagger parent,
                              Merge child)
Rule to merge Tagger with Merge. This method will iterate through the children of the merge, and merge the child of the merge with the parent if the child is a tagger operator.
Parameters:
parent - The parent Tagger operator.
child - The child Merge operator.
Returns:
ReWriteResult. The swap flag in ReWriteResult true if the nodes were swapped, false otherwise.
Since:
1.0
See Also:
Tagger, Merge

visit

public java.lang.Object visit(Tagger parent,
                              Tagger child)
Rule to merge Tagger with Tagger
Parameters:
parent - The parent Tagger operator.
child - The child Tagger operator.
Returns:
ReWriteResult. The swap flag in ReWriteResult true if the nodes were swapped, false otherwise.
Since:
1.0
See Also:
Tagger