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.
-
alias
- Alias of this Relation.
-
objnum
- debug variable to trace how many relation object created.
-
theExtent
-
-
theName
-
-
theSchema
-
-
Relation()
-
-
Relation(FileInputStream)
-
-
Relation(ResultSet, String)
- this is a constructor of Relation from result set.
-
Relation(ResultSet, String, Relation, String)
- This constructor will create a Relation from Resultset.
-
Relation(ResultSet, String, String)
- This constructor will create a Relation from Resultset.
-
Relation(ResultSet, String, String, String)
- This constructor will create a Relation from Resultset.
-
Relation(String)
-
-
clone()
-
-
createTableSQL()
-
-
createTableSQL(String)
- This function will create a table with sign field.
-
delCol(String)
- Delete one column from the Relation
-
finalize()
-
-
getAlias()
-
-
getCardinality()
-
-
getCommon(Relation)
-
-
getExtent()
-
-
getName()
-
-
getSchema()
- get Schema of this Relation.
-
initIterator()
- Cooperate with moreTuple and InsertTupleSQL, TupleSQL.
-
insertTuple(Tuple)
-
-
insertTupleSQL(StringBuffer)
- Cooperate with moreTuple and initIterator.
-
insertTupleSQL(StringBuffer, String)
- Cooperate with moreTuple and initIterator.
-
join(Relation)
- This method will join two relations and return the result.
-
joinVirtual(Relation)
- This method will join two relations and return the result.
-
joinVirtualOn(Relation, Hashtable)
- This method will join two relations and return the result.
-
makeConditions(StringBuffer)
- This function will generate the conditions from Relation Schema and the Tuple
This function should be only used by method: insertTupleSQL().
-
minus(Relation)
-
-
moreTuple()
- Cooperate with initIterator and InsertTupleSQL, TupleSQL.
-
plus(Relation)
-
-
projectOn(Relation)
- Do Project Operation.
-
rename(String)
- Give this Relation a new name
-
setAlias(String)
-
-
setExtent(RelationExtent)
- This function set the new extent of this relation.
-
setName(String)
- Set New name for this relation.
-
setSchema(RelationSchema)
-
-
toString()
- Convert Relation to String
-
updateTupleSQL(StringBuffer)
- Cooperate with moreTuple and initIterator.
-
write(FileOutputStream)
-
theName
String theName
alias
String alias
- Alias of this Relation. It used for Join Condition to keep track of
Where this Relation comes from.
theSchema
RelationSchema theSchema
theExtent
RelationExtent theExtent
objnum
static int objnum
- debug variable to trace how many relation object created.
Relation
private Relation()
Relation
public Relation(ResultSet rs,
String newName) throws Exception
- this is a constructor of Relation from result set.
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.
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.
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.
Relation
public Relation(String newName)
Relation
public Relation(FileInputStream fin)
finalize
public void finalize()
- Overrides:
- finalize in class Object
clone
public Object clone()
- Overrides:
- clone in class Object
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.
getAlias
public String getAlias()
setAlias
public void setAlias(String newname)
setSchema
public void setSchema(RelationSchema newSchema)
insertTuple
public void insertTuple(Tuple newTuple) throws Exception
createTableSQL
public String createTableSQL()
createTableSQL
public String createTableSQL(String sign)
- This function will create a table with sign field.
e.g. "col1, col2" will be "SWEEPSIGN, col1, col2"
initIterator
public void initIterator()
- Cooperate with moreTuple and InsertTupleSQL, TupleSQL.
moreTuple
public boolean moreTuple()
- Cooperate with initIterator and InsertTupleSQL, TupleSQL.
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.
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.
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.
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
getName
public String getName()
getCommon
public String getCommon(Relation theRelation)
getExtent
public RelationExtent getExtent()
write
public void write(FileOutputStream fout)
minus
public Relation minus(Relation sndRelation) throws Exception
plus
public Relation plus(Relation sndRelation)
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.
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.
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.
getCardinality
public int getCardinality()
toString
public String toString()
- Convert Relation to String
- Overrides:
- toString in class Object
rename
public void rename(String newName)
- Give this Relation a new name
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.
getSchema
public RelationSchema getSchema()
- get Schema of this Relation.
setName
public void setName(String newName)
- Set New name for this relation.
delCol
public void delCol(String colName)
- Delete one column from the Relation
All Packages Class Hierarchy This Package Previous Next Index