treeBuilder
Class Builder

java.lang.Object
  |
  +--treeBuilder.Builder

public class Builder
extends java.lang.Object

the algebra tree builder. Parses the SchemaSQL query using package schemaSQLParser and then builds an algebra tree using package algebraTree.


Field Summary
static int ATTNAME
           
private static int DATANAME
           
private static boolean DEBUG
           
static int DOMAIN
           
static int ERROR
           
 java.util.Vector fromClause
           
 java.util.Vector leftoverConstraints
           
private  DBManager localDB
           
private static int PIVOTNAME
           
static int RELNAME
           
private static int RELPIVOTNAME
           
 java.util.Vector selectClause
          any item in the select clause...
private  DBManager sourceDB
          handles for the system's source and local DB connections, to be used in tree-building
static int TUPLE
           
(package private) static java.lang.String[] typeNames
           
 java.util.Vector viewClause
          any items in the view clause...
 java.lang.String viewName
          whatever comes right after the view clause
 
Constructor Summary
Builder(DBManager sourceP, DBManager localP)
           
 
Method Summary
 QENode createAlgebraTree()
          kicks off creation of algebra tree.
private  java.lang.String findFlatAttName(java.lang.String search, java.util.Hashtable varNames, int type)
          searches a value in the variableNames hashtable and returns the pivot (type==TRUE) or data name (type==FALSE) of the node there
private  java.lang.String findFlatAttName2(java.lang.String search, java.util.Hashtable varNames, java.util.Vector joinList)
          another hack :( This function searches for an element in the join list and then goes to a Unite node that is its child.
private  java.lang.String findFlatRelName(java.lang.String search, java.util.Hashtable varNames)
          searches a value in the variableNames hashtable and returns the relname of the node that is hashed there
 tbFromItem findFromItem(java.lang.String tableName)
          finds the fromItem with the given tableName as alias (if present) or name (if no alias)
private  java.util.Vector makeFlattenList(java.util.Vector fromClauseP)
          this method finds all fromitems which should be flattened (i.e., base relations.) in a later version, the sources should be read from a configuration file rather than hardcoded.
private  void saveLocalConstraints(tbFromItem frmItem)
          this stores any local constraint in the parameter from-Item in the global variable leftoverConstraints.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, wait, wait, wait
 

Field Detail

DEBUG

private static final boolean DEBUG

TUPLE

public static final int TUPLE

ATTNAME

public static final int ATTNAME

RELNAME

public static final int RELNAME

DOMAIN

public static final int DOMAIN

ERROR

public static final int ERROR

PIVOTNAME

private static final int PIVOTNAME

DATANAME

private static final int DATANAME

RELPIVOTNAME

private static final int RELPIVOTNAME

viewName

public java.lang.String viewName
whatever comes right after the view clause

viewClause

public java.util.Vector viewClause
any items in the view clause... Strings, for the time being

selectClause

public java.util.Vector selectClause
any item in the select clause... these are "tbSelectItem"s

fromClause

public java.util.Vector fromClause

leftoverConstraints

public java.util.Vector leftoverConstraints

typeNames

static final java.lang.String[] typeNames

sourceDB

private DBManager sourceDB
handles for the system's source and local DB connections, to be used in tree-building

localDB

private DBManager localDB
Constructor Detail

Builder

public Builder(DBManager sourceP,
               DBManager localP)
Method Detail

createAlgebraTree

public QENode createAlgebraTree()
kicks off creation of algebra tree. Must be called after the visitor is done
Returns:
rootnode of the algebraTree

makeFlattenList

private java.util.Vector makeFlattenList(java.util.Vector fromClauseP)
this method finds all fromitems which should be flattened (i.e., base relations.) in a later version, the sources should be read from a configuration file rather than hardcoded. Currently, all sources must even exist in the same source database (since we can't otherwise decide which source comes from which database)
This will keep RELNAME, ATTNAME, and TUPLE variables/
Parameters:
the - fromClause from this class, included as parameter for clarity

saveLocalConstraints

private void saveLocalConstraints(tbFromItem frmItem)
this stores any local constraint in the parameter from-Item in the global variable leftoverConstraints.

findFromItem

public tbFromItem findFromItem(java.lang.String tableName)
finds the fromItem with the given tableName as alias (if present) or name (if no alias)

findFlatRelName

private java.lang.String findFlatRelName(java.lang.String search,
                                         java.util.Hashtable varNames)
searches a value in the variableNames hashtable and returns the relname of the node that is hashed there

findFlatAttName

private java.lang.String findFlatAttName(java.lang.String search,
                                         java.util.Hashtable varNames,
                                         int type)
searches a value in the variableNames hashtable and returns the pivot (type==TRUE) or data name (type==FALSE) of the node there

findFlatAttName2

private java.lang.String findFlatAttName2(java.lang.String search,
                                          java.util.Hashtable varNames,
                                          java.util.Vector joinList)
another hack :( This function searches for an element in the join list and then goes to a Unite node that is its child. The purpose is that for relname items we need the pivot att name from the UNITE-ode, not the fold node above. I forgot about that.... Works only for cases in which the Unite-Operator is a direct child of the Fold-Operator... The case of two nested Fold-Operators is never handled in this implementation. Bug 083100: this doesn't work if there is no fold-node at all. So since I forgot how this works - I'll just introduce a special case that omits the getChild() and hope that it miraculously works. God bless software-engineering...

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object