All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class SWEEP.Relation

java.lang.Object
   |
   +----SWEEP.Element
           |
           +----SWEEP.StampedElement
                   |
                   +----SWEEP.Relation

public class Relation
extends StampedElement
implements Serializable, Cloneable
This is a class represent a Relational Database Table. We can create it from: 1. null 2. ResultSet from JDBC 3. File created by write() method We can following operations on it: 1. Join 2. Plus 3. Minus 4. Projection 5. delColumn Tuple Format: (values)[number] e.g. (5,6)[3] means we have three duplicate (5,6) tuples.


Variable Index

 o alias
Alias of this Relation.
 o objnum
debug variable to trace how many relation object created.
 o theExtent
 o theName
 o theSchema

Constructor Index

 o Relation()
 o Relation(FileInputStream)
 o Relation(ResultSet, String)
this is a constructor of Relation from result set.
 o Relation(ResultSet, String, Relation, String)
This constructor will create a Relation from Resultset.
 o Relation(ResultSet, String, String)
This constructor will create a Relation from Resultset.
 o Relation(ResultSet, String, String, String)
This constructor will create a Relation from Resultset.
 o Relation(String)

Method Index

 o clone()
 o createTableSQL()
 o createTableSQL(String)
This function will create a table with sign field.
 o delCol(String)
Delete one column from the Relation
 o finalize()
 o getAlias()
 o getCardinality()
 o getCommon(Relation)
 o getExtent()
 o getName()
 o getSchema()
get Schema of this Relation.
 o initIterator()
Cooperate with moreTuple and InsertTupleSQL, TupleSQL.
 o insertTuple(Tuple)
 o insertTupleSQL(StringBuffer)
Cooperate with moreTuple and initIterator.
 o insertTupleSQL(StringBuffer, String)
Cooperate with moreTuple and initIterator.
 o join(Relation)
This method will join two relations and return the result.
 o joinVirtual(Relation)
This method will join two relations and return the result.
 o joinVirtualOn(Relation, Hashtable)
This method will join two relations and return the result.
 o makeConditions(StringBuffer)
This function will generate the conditions from Relation Schema and the Tuple This function should be only used by method: insertTupleSQL().
 o minus(Relation)
 o moreTuple()
Cooperate with initIterator and InsertTupleSQL, TupleSQL.
 o plus(Relation)
 o projectOn(Relation)
Do Project Operation.
 o rename(String)
Give this Relation a new name
 o setAlias(String)
 o setExtent(RelationExtent)
This function set the new extent of this relation.
 o setName(String)
Set New name for this relation.
 o setSchema(RelationSchema)
 o toString()
Convert Relation to String
 o updateTupleSQL(StringBuffer)
Cooperate with moreTuple and initIterator.
 o write(FileOutputStream)

Variables

 o theName
 String theName
 o alias
 String alias
Alias of this Relation. It used for Join Condition to keep track of Where this Relation comes from.

 o theSchema
 RelationSchema theSchema
 o theExtent
 RelationExtent theExtent
 o objnum
 static int objnum
debug variable to trace how many relation object created.

Constructors

 o Relation
 private Relation()
 o Relation
 public Relation(ResultSet rs,
                 String newName) throws Exception
this is a constructor of Relation from result set.

 o Relation
 public Relation(ResultSet rs,
                 String newName,
                 String sign) throws Exception
This constructor will create a Relation from Resultset. Important part here, is that this constructor will search for the "SWEEPSIGN" field. if it is 'p', means positive; if it is 'n', means negative.

 o Relation
 public Relation(ResultSet rs,
                 String newName,
                 Relation localrel,
                 String sign) throws Exception
This constructor will create a Relation from Resultset. Important part here, is that this constructor will search for the "SWEEPSIGN" field. if it is 'p', means positive; if it is 'n', means negative.

 o Relation
 public Relation(ResultSet rs,
                 String newName,
                 String sign1,
                 String sign2) throws Exception
This constructor will create a Relation from Resultset. Important part here, is that this constructor will search for the "SWEEPSIGN1" field and "SWEEPSIGN2" field. if they are same, means positive; otherwise, means negative.

 o Relation
 public Relation(String newName)
 o Relation
 public Relation(FileInputStream fin)

Methods

 o finalize
 public void finalize()
Overrides:
finalize in class Object
 o clone
 public Object clone()
Overrides:
clone in class Object
 o setExtent
 public void setExtent(RelationExtent newExtent)
This function set the new extent of this relation. It should check the consistency of current schema and current extent, but I haven't implement it.

 o getAlias
 public String getAlias()
 o setAlias
 public void setAlias(String newname)
 o setSchema
 public void setSchema(RelationSchema newSchema)
 o insertTuple
 public void insertTuple(Tuple newTuple) throws Exception
 o createTableSQL
 public String createTableSQL()
 o createTableSQL
 public String createTableSQL(String sign)
This function will create a table with sign field. e.g. "col1, col2" will be "SWEEPSIGN, col1, col2"

 o initIterator
 public void initIterator()
Cooperate with moreTuple and InsertTupleSQL, TupleSQL.

 o moreTuple
 public boolean moreTuple()
Cooperate with initIterator and InsertTupleSQL, TupleSQL.

 o updateTupleSQL
 public int updateTupleSQL(StringBuffer Query)
Cooperate with moreTuple and initIterator. This function is only used for Create Temporary Table in Oracle. So, this function will ASSUME all the QUERYNUMBER should be POSITIVE. if the QUERYNUMBER is negative, it will genereate "delete" query.

 o insertTupleSQL
 public int insertTupleSQL(StringBuffer Query)
Cooperate with moreTuple and initIterator. This function is only used for Create Temporary Table in Oracle. So, this function will ASSUME all the QUERYNUMBER should be POSITIVE. if the QUERYNUMBER is negative, it will genereate "delete" query.

 o insertTupleSQL
 public int insertTupleSQL(StringBuffer Query,
                           String sign)
Cooperate with moreTuple and initIterator. This function is only used for Create Temporary Table in Oracle. So, this function will ASSUME all the QUERYNUMBER should be POSITIVE. if the QUERYNUMBER is negative, it will genereate "delete" query.

 o makeConditions
 private String makeConditions(StringBuffer tupleValues) throws Exception
This function will generate the conditions from Relation Schema and the Tuple This function should be only used by method: insertTupleSQL(). The input stringbuffer should fit in such format: value1,value2,value3

 o getName
 public String getName()
 o getCommon
 public String getCommon(Relation theRelation)
 o getExtent
 public RelationExtent getExtent()
 o write
 public void write(FileOutputStream fout)
 o minus
 public Relation minus(Relation sndRelation) throws Exception
 o plus
 public Relation plus(Relation sndRelation)
 o join
 public Relation join(Relation sndRelation)
This method will join two relations and return the result. It is assumed the second Relation is already in the database.

 o joinVirtual
 public Relation joinVirtual(Relation sndRelation)
This method will join two relations and return the result. It is assumed both relation are not on the database.

 o joinVirtualOn
 public Relation joinVirtualOn(Relation sndRelation,
                               Hashtable JCAttrs)
This method will join two relations and return the result. It is assumed both relation are not on the database.

 o getCardinality
 public int getCardinality()
 o toString
 public String toString()
Convert Relation to String

Overrides:
toString in class Object
 o rename
 public void rename(String newName)
Give this Relation a new name

 o projectOn
 public void projectOn(Relation Rel) throws Exception
Do Project Operation. Project will project this relation on specific relation's schema. Here the new Relation's schema must be a subset of this relation's schema.

 o getSchema
 public RelationSchema getSchema()
get Schema of this Relation.

 o setName
 public void setName(String newName)
Set New name for this relation.

 o delCol
 public void delCol(String colName)
Delete one column from the Relation


All Packages  Class Hierarchy  This Package  Previous  Next  Index