edu.wpi.cs.dsrg.xmldb.xat.component.operatorexec
Class ExecuteVisitor

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

public class ExecuteVisitor
extends InheritableVisitor

The ExecuteVisitor class is part of the visitor pattern that is used here to perform the execution of opertors in an XAT tree.

Since:
1.0

Constructor Summary
ExecuteVisitor()
          Constructor.
ExecuteVisitor(java.lang.String db, java.lang.String username, java.lang.String password)
          Assigns database connection, user name, and a passward.
 
Method Summary
 java.lang.Object dispatch()
          Used to implement a visitor pattern.
 java.lang.Object dispatch(java.lang.Object obj)
          Used to implement a visitor pattern.
 java.lang.Object dispatch(java.lang.Object obj1, java.lang.Object obj2)
          Used to implement a visitor pattern.
 XATTable execute(XATTree xtree)
          Constructor, visits a tree.
 XATTable execute(XATTree xtree, XATTable input)
          Executes a tree with a given input.
 boolean isAbort()
          Gets Abort Info.
 boolean isDebug()
          Gets debug info.
 boolean isKeepClone()
          System environment to test if we want to keep a clone of XATTable or not.
 boolean isShowTable()
          System environment from testing.
protected  edu.wpi.cs.dsrg.xmldb.xat.component.operatorexec.ExecuteVisitor.ColumnRef lookupColumn(XATNode xnode, java.lang.String colname)
           
protected  XATTable nest(java.lang.String col, XATTable table)
          Creates collections for the values of nested column.
 java.lang.Object visit(Aggregate agg)
          Execution for the Aggregate operator, part of the visitor pattern.
 java.lang.Object visit(CartesianProduct cp)
           
 void visit(Composer comp)
          Execution for the Composer operator, part of the visitor pattern.
 java.lang.Object visit(Difference diff)
          Execution for the Difference operator, part of the visitor pattern.
 java.lang.Object visit(Distinct d)
           
 java.lang.Object visit(Expose exp)
          Execution for the Expose operator, part of the visitor pattern.
 java.lang.Object visit(FOR forop)
           
 java.lang.Object visit(Function func)
          Execution for the Function operator, part of the visitor pattern.
 java.lang.Object visit(GroupBy gb)
          Execution for the GroupBy operator, part of the visitor pattern.
 java.lang.Object visit(Intersection inter)
          Execution for the Intersection operator, part of the visitor pattern.
 java.lang.Object visit(LeftOuterJoin loj)
          Execution for the LeftOuterJoin operator, part of the visitor pattern.
 java.lang.Object visit(LeftSemiJoin lsj)
           
 java.lang.Object visit(Merge merIm)
           
 java.lang.Object visit(NameColumn nc)
          Execution for the NameColumn operator, part of the visitor pattern.
 java.lang.Object visit(NavCollection n)
          Execution for the NavCollection operator, part of the visitor pattern.
 java.lang.Object visit(NavUnnest n)
          Execution for the NavUnnest operator, part of the visitor pattern.
 java.lang.Object visit(java.lang.Object object)
          Used to implement the visitor pattern.
 java.lang.Object visit(OrderBy ob)
          Execution for the OrderBy operator, part of the visitor pattern.
 java.lang.Object visit(OuterUnion ou)
           
 java.lang.Object visit(Project p)
          Execution for the Project operator, part of the visitor pattern.
 java.lang.Object visit(RightOuterJoin roj)
          Execution for the RightOuterJoin operator, part of the visitor pattern.
 java.lang.Object visit(RightSemiJoin rsj)
          Execution for the RightSemiJoin operator, part of the visitor pattern.
 java.lang.Object visit(Select s)
          Execution for the Select operator, part of the visitor pattern.
 java.lang.Object visit(Source s)
           
 void visit(SQLStmt sqlstmt)
           
 java.lang.Object visit(Tagger t)
          Execution for the Tagger operator, part of the visitor pattern.
 java.lang.Object visit(ThetaJoin tj)
          Execution for the ThetaJoin operator, part of the visitor pattern.
 java.lang.Object visit(Union u)
          Execution for the Union operator, part of the visitor pattern.
 java.lang.Object visit(XATNode xnoObj)
           
 java.lang.Object visit(XATTree tree)
           
 java.lang.Object visit(XMLDifference xdiff)
          Execution for the XMLDifference operator, part of the visitor pattern.
 java.lang.Object visit(XMLIntersection xintersect)
          Execution for the XMLIntersection operator, part of the visitor pattern.
 java.lang.Object visit(XMLUnion xun)
          Execution for the XMLUnion operator, part of the visitor pattern.
 
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

ExecuteVisitor

public ExecuteVisitor()
Constructor.
Parameters:
XATNode - edu.wpi.cs.dsrg.xmldb.xat.common.xatnode.XATNode
Since:
1.0

ExecuteVisitor

public ExecuteVisitor(java.lang.String db,
                      java.lang.String username,
                      java.lang.String password)
Assigns database connection, user name, and a passward.
Parameters:
db - - database connection address
username - - database account username
password - - database account password
Since:
1.0
Method Detail

dispatch

public java.lang.Object dispatch()
Used to implement a visitor pattern.
Overrides:
dispatch in class InheritableVisitor
Returns:
null
Since:
1.0

dispatch

public java.lang.Object dispatch(java.lang.Object obj)
Used to implement a visitor pattern.
Overrides:
dispatch in class InheritableVisitor
Parameters:
obj - Object
Returns:
null
Since:
1.0

dispatch

public java.lang.Object dispatch(java.lang.Object obj1,
                                 java.lang.Object obj2)
Used to implement a visitor pattern.
Parameters:
obj1 - Object
obj2 - Object
Returns:
null
Since:
1.0

execute

public XATTable execute(XATTree xtree)
Constructor, visits a tree.
Parameters:
xtree - tree containing differnet XAT nodes
Returns:
The resulting XATTable after all nodes have been executed
Since:
1.0

execute

public XATTable execute(XATTree xtree,
                        XATTable input)
Executes a tree with a given input.
Parameters:
xtree - tree containing a mix of SQL and XML nodes
input - XATTable is the input XAT table.
Returns:
the resulting XATTable after all nodes have been executed
Since:
1.0

isAbort

public boolean isAbort()
Gets Abort Info.
Returns:
boolean
Since:
1.0

isDebug

public boolean isDebug()
Gets debug info.
Returns:
boolean
Since:
1.0

isKeepClone

public boolean isKeepClone()
System environment to test if we want to keep a clone of XATTable or not. We keep clone for DEMO. We don't keep clone for EXP and Performance.
Returns:
boolean
Since:
1.0

isShowTable

public boolean isShowTable()
System environment from testing.
Returns:
boolean
Since:
1.0

lookupColumn

protected edu.wpi.cs.dsrg.xmldb.xat.component.operatorexec.ExecuteVisitor.ColumnRef lookupColumn(XATNode xnode,
                                                                                                 java.lang.String colname)

nest

protected XATTable nest(java.lang.String col,
                        XATTable table)
Creates collections for the values of nested column. It uses Hashtable to help the nesting. The final output order decided by the first-appearence of un-nested column values. it will nest on the id of each cell.
Parameters:
col - String
table - XATTable
Returns:
XATTable
Since:
1.0

visit

public java.lang.Object visit(Expose exp)
                       throws ExecutionInvalidXATTreeException
Execution for the Expose operator, part of the visitor pattern. Only keep the exposed columns in the output XAT table. All other columns are removed.
Parameters:
exp - is the Expose opertor.
Returns:
null
Since:
1.0

visit

public java.lang.Object visit(FOR forop)

visit

public java.lang.Object visit(Function func)
Execution for the Function operator, part of the visitor pattern. Function F(param1..m)[s1..n] Input: Multiple tables s1..n. Output: Temporary table. Logic: Execute some user defined function on the data sources. Or, used to represent a recursive query. Order Handling: Schema and tuple orders depend on the implementation. They can be reconfirmed by projection and orderby nodes.
Parameters:
func - is the Function opertor.
Returns:
null
Since:
1.0

visit

public java.lang.Object visit(Merge merIm)
                       throws XATNodeDoesNotExistException,
                              XATTableTupleNoMatchException

visit

public java.lang.Object visit(NameColumn nc)
                       throws ExecutionInvalidXATTreeException
Execution for the NameColumn operator, part of the visitor pattern. Input: Table s. Output: Table s. Logic: Rename col1 in table s into col2. Order Handling: Keep all the schema and tuple orders. Requirement: Col1 in table s.
Parameters:
NameColumn - is the NameColumn opertor.
Returns:
null
Since:
1.0

visit

public java.lang.Object visit(Source s)

visit

public void visit(SQLStmt sqlstmt)

visit

public java.lang.Object visit(CartesianProduct cp)
                       throws XATNodeDoesNotExistException

visit

public java.lang.Object visit(Difference diff)
                       throws XATTableSchemaNoMatchException
Execution for the Difference operator, part of the visitor pattern. Difference diff(Table[]) Input: n number of tables. Output: table r. Logic: This operation will compare n number of tables and return a result table r that retains tuples that do not match from table to table. Requirement: The table schemas are identical, same number of columns and the same name for each column.
Parameters:
diff - is the Difference opertor.
Returns:
null
Since:
1.0

visit

public java.lang.Object visit(Distinct d)

visit

public java.lang.Object visit(GroupBy gb)
                       throws ExecutionInvalidXATTreeException
Execution for the GroupBy operator, part of the visitor pattern. Groupby GB(col1..n, F1..m(col))[s] Input: table s. Output: table s. Logic: Same as SQL. Order Handling: The schema order of the output table is col1..n followed by F1..m(col). The tuple order of the output table is no longer kept. Requirement: col1..n and all the col in the F1..m should be in table s.
Parameters:
gb - is the GroupBy opertor.
Returns:
null
Since:
1.0

visit

public java.lang.Object visit(Intersection inter)
                       throws XATTableSchemaNoMatchException
Execution for the Intersection operator, part of the visitor pattern. Intersect Inter(Table[]) Input: n number of tables. Output: table r. Logic: This operation will compare n number of tables and return a result table r that retains tuples that match with each table. Order Handling: The ouput table order is the same as the left input table order Requirement: The table schemas are identical, same number of columns and the same name for each column.
Parameters:
inter - is the Intersection opertor.
Returns:
null
Throws:
XATTableSchemaNoMatchException -  
Since:
1.0

visit

public java.lang.Object visit(LeftOuterJoin loj)
                       throws ExecutionInvalidXATTreeException
Execution for the LeftOuterJoin operator, part of the visitor pattern. Left Outer Join LOJ(c)[l, r] Input: table l, and table r. Output: One table (with temporary table name) Logic: Same as SQL. Order Handling: The schema order of the output table is columns of table l followed by the columns of table r. The tuple order of the output table is iteration of tuples in r over the iteration of tuples in l, e.g., {, , , , } Requirement: Condition c should be relates to both tables l and r.
Parameters:
loj - is the LeftOuterJoin opertor.
Returns:
null
Throws:
ExecutionInvalidXATTreeException -  
Since:
1.0

visit

public java.lang.Object visit(LeftSemiJoin lsj)

visit

public java.lang.Object visit(OrderBy ob)
                       throws XATNodeDoesNotExistException
Execution for the OrderBy operator, part of the visitor pattern. Orderby OB(col1..n)[s] Input: table s. Output: table s. Logic: Same as SQL. Order Handling: The schema order of the output table is same as table s. The tuple order of the output table is as specified. Requirement: col1..n should be in table s.
Parameters:
ob - is the OrderBy opertor.
Returns:
null
Throws:
XATNodeDoesNotExistException -  
Since:
1.0

visit

public java.lang.Object visit(OuterUnion ou)
                       throws XATNodeDoesNotExistException

visit

public java.lang.Object visit(Project p)
                       throws XATNodeDoesNotExistException
Execution for the Project operator, part of the visitor pattern. Project Pi(col1..n)[s] Input: table s Output: table s Logic: Same as SQL. Order Handling: Keeps original tuple order, the schema order is reordered as the col1..n in the project operator. Requirement: The col1..n should be in source s.
Parameters:
p - is the Project opertor.
Returns:
null
Throws:
XATNodeDoesNotExistException -  
Since:
1.0

visit

public java.lang.Object visit(RightOuterJoin roj)
                       throws XATNodeDoesNotExistException
Execution for the RightOuterJoin operator, part of the visitor pattern. Uses same logic as leftOuterJoin. Just switch the Left and Right.
Parameters:
roj - is the RightOuterJoin opertor.
Returns:
null
Throws:
XATNodeDoesNotExistException -  
Since:
1.0
See Also:
LeftOuterJoin

visit

public java.lang.Object visit(RightSemiJoin rsj)
                       throws XATNodeDoesNotExistException
Execution for the RightSemiJoin operator, part of the visitor pattern. Uses same logic as leftSemiJoin. Just switch the Left and Right.
Parameters:
rsj - is the RightSemiJoin opertor.
Returns:
null
Throws:
XATNodeDoesNotExistException -  
Since:
1.0
See Also:
LeftSemiJoin

visit

public java.lang.Object visit(Select s)
                       throws XATNodeDoesNotExistException
Execution for the Select operator, part of the visitor pattern. Select Theta(c)[s] Input: table s Output: table s Logic: Same as SQL. Order Handling: Keep original tuple order, keep original schema order. Requirement: Condition c should be only reference to the source s.
Parameters:
s - is the Select opertor.
Returns:
null
Throws:
XATNodeDoesNotExistException -  
Since:
1.0

visit

public java.lang.Object visit(ThetaJoin tj)
                       throws XATNodeDoesNotExistException
Execution for the ThetaJoin operator, part of the visitor pattern. Input: table l, and table r. Output: One table (with temporary table name) Logic: Same as SQL. Order Handling: The schema order of the output table is columns of table l followed by the columns of table r. The tuple order of the output table is iteration of tuples in r over the iteration of tuples in l, e.g., {, , , } Requirement: Condition c should be relates to both tables l and r.
Parameters:
tj - is the ThetaJoin opertor.
Returns:
null
Throws:
XATNodeDoesNotExistException -  
Since:
1.0

visit

public java.lang.Object visit(Union u)
                       throws XATNodeDoesNotExistException,
                              XATTableSchemaNoMatchException
Execution for the Union operator, part of the visitor pattern. Input: Multiple tables s1..n. Output: One table (with temporary name). Logic: Same as SQL. Order Handling: The schema order of the output table is same as table s1. The tuple order of the output table is in the order of table s1..n. Requirement: All tables s1..n have same schema
Parameters:
u - is the Union opertor.
Returns:
null
Throws:
XATNodeDoesNotExistException, - XATTableSchemaNoMatchException
Since:
1.0

visit

public java.lang.Object visit(Aggregate agg)
Execution for the Aggregate operator, part of the visitor pattern. Aggregate Agg(F1..m(col))[s] Input: table s. Output: table s. Logic: Merge all tuples in that table into one, and apply functions on those columns. If there are no functions, then just merge all the content. Order Handling: The schema order of the output table is F1..m(col). There is only one tuple. Also, within each cell, the duplicates should be removed from that collection except the fucus collom Requirement: All the col in the F1..m should be in table s.
Parameters:
agg - is the Aggregate opertor.
Returns:
null
Since:
1.0

visit

public void visit(Composer comp)
Execution for the Composer operator, part of the visitor pattern. Input: table s. Output: an XML document. Logic: This method results in a complete XML document by using the contents and structure of the data model to determine the structure of the XML document. Order Handling: Requirement: It is a special purpose XML cosntruction opertor that will only be avaialbe after SQL generation and optimization.
Parameters:
comp - is the Composer opertor.
Returns:
null
Since:
1.0

visit

public java.lang.Object visit(NavCollection n)
                       throws ExecutionInvalidXATTreeException
Execution for the NavCollection operator, part of the visitor pattern. Input: table s. Output: table s. Logic: The NavCollection operator will only create the new collection instead of unnesting the parent tuples. We adopt the algorithm from Navigate Unnesting. The difference is: we don't duplicate the parent tuples, and directly put the output column in it. Order Handling: the tuple order on the output XAT table follows the order of the input XAT table. Requirement:
Parameters:
n - is the NavCollection opertor.
Returns:
null
Throws:
ExecutionInvalidXATTreeException -  
Since:
1.0

visit

public java.lang.Object visit(NavUnnest n)
                       throws ExecutionInvalidXATTreeException
Execution for the NavUnnest operator, part of the visitor pattern. Input: table s. Output: table s. Logic: The NavUnnest operator will unnest the parent tuples. A new column is appended to the output XAT table each parent tuple is duplicated in the output table for each unnested value from that tuple, the unnested value appers in the new column, and if there is nothing to unnest from an input tuple an empty collection is placed in the new column Order Handling: the tuple order on the output XAT table follows the order of the input XAT table. Requirement:
Parameters:
n - is the NavUnnest opertor.
Returns:
null
Throws:
ExecutionInvalidXATTreeException -  
Since:
1.0

visit

public java.lang.Object visit(Tagger t)
Execution for the Tagger operator, part of the visitor pattern. Tagger Tag(p)[s] Input: Table s. Output: Table s. Logic: One additional column is added with tagged information. Pattern p is only one level. Order Handling: The tagged column is added to the end. The tuple order of the output table is same as table s. Requirement: The columns used in pattern p should be in table s.
Parameters:
t - is the Tagger opertor.
Returns:
null
Since:
1.0

visit

public java.lang.Object visit(XMLDifference xdiff)
                       throws XATNodeDoesNotExistException,
                              XATTableSchemaNoMatchException
Execution for the XMLDifference operator, part of the visitor pattern. Input: Table s. Output: Table s. Logic: Takes the difference of two columns. The first col minus the second col. Order Handling: Requirement:
Parameters:
xdiff - is the XMLDifference opertor.
Returns:
null
Throws:
XATNodeDoesNotExistException, - XATTableSchemaNoMatchException
Since:
1.0

visit

public java.lang.Object visit(XMLIntersection xintersect)
                       throws XATNodeDoesNotExistException,
                              XATTableSchemaNoMatchException
Execution for the XMLIntersection operator, part of the visitor pattern. Input: Table s. Output: Table s. Logic: Takes the intersection of two columns. The first col intersect the second col. Order Handling: Requirement:
Parameters:
xintersect - is the XMLIntersection opertor.
Returns:
null
Throws:
XATNodeDoesNotExistException, - XATTableSchemaNoMatchException
Since:
1.0

visit

public java.lang.Object visit(XMLUnion xun)
                       throws XATNodeDoesNotExistException
Execution for the XMLUnion operator, part of the visitor pattern. Input: Table s. Output: Table s. Logic: Merges XML tables into one table. Each table will have relevant columns but the merged tables, will not. Hence alot of values will be null. Order Handling: Requirement:
Parameters:
xun - is the XMLUnion opertor.
Returns:
null
Throws:
XATNodeDoesNotExistException -  
Since:
1.0

visit

public java.lang.Object visit(XATTree tree)

visit

public java.lang.Object visit(XATNode xnoObj)

visit

public java.lang.Object visit(java.lang.Object object)
Used to implement the visitor pattern. Overwrite this method in the parent class. If there is an inheretance between the visited objects, it will only match the highest class. Note: Different from it's super class, this method will abort if "AbortOnException" system property is set.
Overrides:
visit in class InheritableVisitor
Parameters:
object - Object
Returns:
Object
Since:
1.0