algebraTree
Class SchemaSQLOperator

java.lang.Object
  |
  +--algebraTree.SchemaSQLOperator
Direct Known Subclasses:
Fold, Split, StandardSQL, Unfold, Unite

public abstract class SchemaSQLOperator
extends java.lang.Object


Field Summary
protected  boolean isLeaf
          for intermediate results
static boolean LEAF
          these are DEFINEs for the Leafness status of an operator
protected  DBManager localDB
          for intermediate results
protected  java.lang.String localQuery
          I forgot what this was for...
static boolean NOLEAF
          these are DEFINEs for the Leafness status of an operator
protected  java.lang.String outputTableName
          the name of the output table of this operator.
(package private)  Table pivotData
          operator stores its pivotData for incremental update propagation.
(package private)  DBManager sourceDB
          currently, only one source DB is supported.
 
Constructor Summary
SchemaSQLOperator(DBManager myLocalDB, boolean leafness)
           
 
Method Summary
protected  boolean addPivot(java.lang.String pivotName)
          add a pivot string to the pivot vector.
private  boolean changePivotCount(java.lang.String pivotName, int increment)
          change the pivot count for a certain element by a certain amount.
protected abstract  java.util.Vector computeLocalQueries()
          returns a vector of strings of queries that have to be executed for this operator
protected  boolean decPivotCount(java.lang.String pivotName)
          decrement pivot count.
protected  boolean delPivot(java.lang.String pivotName)
          delete a pivot string from the pivot vector.
protected  boolean dropLocalTable()
          drops this operator's table from the DB.
protected  boolean executeQuery()
          executes all queries returned by computeLocalQueries().
protected  boolean executeQuery(java.lang.String SQL)
          Executes a query passed in a parameter against this node's database.
protected  Table executeUpdateQuery(java.lang.String tableName, java.util.Vector schema, Table updateTable)
          this function builds an update query for data-changes and executes it.
(package private)  void executeUpdates(java.util.Vector updates)
          This function takes a vector of updates and applies it to the outputRelation of this operator.
protected  void finalize()
          in the finalize method we drop local tables.
protected  int findPivotCount(java.lang.String pivotName)
           
 java.lang.String getRelName()
          this is needed to find out what table name this operator has used.
protected  boolean incPivotCount(java.lang.String pivotName)
          increments the count for a pivot element in this operator's (materialized) pivot vector.
(package private)  java.util.Vector propagateUpdate(Update upd)
          every operator must know how to propagate incremental updates of any kind.
 void setQuery(java.lang.String s)
           
(package private)  void setRelName(java.lang.String s)
          sets the relation name of this operator.
 boolean setSourceDB(DBManager setSourceDB)
           
(package private)  java.util.Vector tableToDeleteUpdates(java.lang.String tableName, Table delta)
          this function translates all tuples in delta into delete-tuple updates in table tableName
 
Methods inherited from class java.lang.Object
, clone, equals, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

LEAF

public static final boolean LEAF
these are DEFINEs for the Leafness status of an operator

NOLEAF

public static final boolean NOLEAF
these are DEFINEs for the Leafness status of an operator

localDB

protected DBManager localDB
for intermediate results

isLeaf

protected boolean isLeaf
for intermediate results

localQuery

protected java.lang.String localQuery
I forgot what this was for... :(

outputTableName

protected java.lang.String outputTableName
the name of the output table of this operator. Makes no sense for SPLIT

pivotData

Table pivotData
operator stores its pivotData for incremental update propagation. This is a table with all distinct values of the base table (String) plus their multiplicity (number of occurrences) as a String too (!). This table will be valid only after the initial call to computeResult() and will then be maintained incrementally;

sourceDB

DBManager sourceDB
currently, only one source DB is supported. Distributed sources can be simulated by having "select * from"-StandardSQL-nodes that essentially copy base data to the local DB
Constructor Detail

SchemaSQLOperator

public SchemaSQLOperator(DBManager myLocalDB,
                         boolean leafness)
Method Detail

finalize

protected void finalize()
in the finalize method we drop local tables. I'm not sure if this will work since the finalize method behaves somewhat weird.
Overrides:
finalize in class java.lang.Object

setQuery

public void setQuery(java.lang.String s)

getRelName

public java.lang.String getRelName()
this is needed to find out what table name this operator has used. Mainly needed for the root node. Must be public since it's used in Builder::flatRelName

setRelName

void setRelName(java.lang.String s)
sets the relation name of this operator. Is needed from the outside to set the name of the root-operator's relation so the wrapper can produce named tables.

setSourceDB

public boolean setSourceDB(DBManager setSourceDB)

executeQuery

protected boolean executeQuery(java.lang.String SQL)
Executes a query passed in a parameter against this node's database. Uses DBManager.executeViewQuery() since executeQuery() needs relation names in the SQL which we don't have.

executeQuery

protected boolean executeQuery()
executes all queries returned by computeLocalQueries(). This is quite primitive and overridden by the Unfold and Split operators!

dropLocalTable

protected boolean dropLocalTable()
drops this operator's table from the DB. Table will not be dropped if algebraTree.Main.DEBUG is true and in all cases the drop will be silent (error messages suppressed)

computeLocalQueries

protected abstract java.util.Vector computeLocalQueries()
returns a vector of strings of queries that have to be executed for this operator

executeUpdates

void executeUpdates(java.util.Vector updates)
This function takes a vector of updates and applies it to the outputRelation of this operator. Probably needs to be overwritten for the Split-Class

propagateUpdate

java.util.Vector propagateUpdate(Update upd)
every operator must know how to propagate incremental updates of any kind. This method should be abstract in this class as soon as the code is done. The function returns a vector of Updates that were generated in the propagation. Some propagations can not be expressed in this way.

findPivotCount

protected int findPivotCount(java.lang.String pivotName)

incPivotCount

protected boolean incPivotCount(java.lang.String pivotName)
increments the count for a pivot element in this operator's (materialized) pivot vector. The pivot vector (pivot table) serves as a store for pivot elements (it's the paper's A^*) and is actually not really necessary since we query the output table every time anyway. But since this is not something we're proud of, we will just keep having the pivot vector around.

decPivotCount

protected boolean decPivotCount(java.lang.String pivotName)
decrement pivot count. @see incPivotCount(String)

changePivotCount

private boolean changePivotCount(java.lang.String pivotName,
                                 int increment)
change the pivot count for a certain element by a certain amount. Should be called only from @see incPivotCount(String) and @see decPivotCount(String)

addPivot

protected boolean addPivot(java.lang.String pivotName)
add a pivot string to the pivot vector. @return false if pivot exists

delPivot

protected boolean delPivot(java.lang.String pivotName)
delete a pivot string from the pivot vector. @return false if pivot doesn't exist.

executeUpdateQuery

protected Table executeUpdateQuery(java.lang.String tableName,
                                   java.util.Vector schema,
                                   Table updateTable)
this function builds an update query for data-changes and executes it. It returns the table object with the result.
Parameters:
tableName - is the name of the table to be queried
relSchema - is a vector of strings holding the attribute names to be added to the where-clause
updateTable - is a table with attribute names and values (the update to be constructed).

tableToDeleteUpdates

java.util.Vector tableToDeleteUpdates(java.lang.String tableName,
                                      Table delta)
this function translates all tuples in delta into delete-tuple updates in table tableName