Turtle DB
A mini DDBMS
ca.uqac.dim.ddb.Table Class Reference
Inheritance diagram for ca.uqac.dim.ddb.Table:
ca.uqac.dim.ddb.Relation

List of all members.

Public Member Functions

 Table (String s)
 Table (Schema sch)
void setName (String name)
String getName ()
Schema getSchema ()
void put (Tuple t)
Tuple internalNext ()
void remove ()
void reset ()
void accept (QueryVisitor v) throws QueryVisitor.VisitorException
void copy (Relation r)
int getCardinality ()
boolean contains (Tuple tup)
int tupleCount ()

Protected Member Functions

 Table ()

Protected Attributes

List< Tuplem_tuples
Schema m_schema
int m_cursor
String m_name

Constructor & Destructor Documentation

ca.uqac.dim.ddb.Table.Table ( ) [protected]

Empty constructor. Should only be called from another constructor.

Builds a table from a character string. The string must follow these conventions:

  • Any leading or trailing whitespace on a line is ignored
  • Empty lines and lines starting with # or --- are ignored
  • The first non-ignored line is a comma- or space-separated list of attribute names
  • The remaining non-ignored lines are comma- or space-separated list of attribute values, making a tuple
Parameters:
s

Creates an empty table with given schema

Parameters:
schThe table's schema

Member Function Documentation

void ca.uqac.dim.ddb.Table.accept ( QueryVisitor  v) throws QueryVisitor.VisitorException [virtual]

Determines if a relation contains a given tuple. Contrarily to the generic implementation of contains, the method for instances of Table is efficient, as it simply calls the contains method of the underlying list of tuples. It does not present the side effects (reset of enumeration) that the generic method has.

Parameters:
tupThe tuple to look for
Returns:
True if the tuple is present, false otherwise

Reimplemented from ca.uqac.dim.ddb.Relation.

Copies the contents of a relation into the current relation. In particular, invoking copy with a query tree triggers the computation of that query and the storing of the resulting tuples into the current relation.

Parameters:
rThe relation to copy from

Computes the cardinality of a relation. Except for instances of Table (which actually contain concrete tuples), calling this method will trigger the evaluation of the query tree and the enumeration of all tuples. It should be used sparingly.

Returns:
The number of tuples in the relation

Reimplemented from ca.uqac.dim.ddb.Relation.

Gives the table's name

Returns:
The table's name

Returns the relation's schema

Returns:
The schema

Implements ca.uqac.dim.ddb.Relation.

Method that must be implemented by every non-abstract relation; it returns the next tuple of the enumeration, if any. Methods next and hasNext use the return value of internalNext and additionally remove any duplicate tuples from the output enumeration. Hence a call to next may result in multiple calls to the relation's internalNext, if the tuples returned are already part of the result (this is especially true of Projections.

Returns:
The next tuple, null if no such tuple exists

Implements ca.uqac.dim.ddb.Relation.

Adds a new tuple to the table. It is assumed that the tuple's degree is equal to the schema's degree. An assertion fails otherwise (but no exception is raised).

Parameters:
tThe tuple to add

Resets the enumeration of tuples, i.e. starts back at the first tuple of the relation.

Reimplemented from ca.uqac.dim.ddb.Relation.

void ca.uqac.dim.ddb.Table.setName ( String  name)

Set the table's name.

Parameters:
nameThe table's name

Returns the number of actual tuples present in the query. This number is different from the cardinality of the query; it counts the number of tuples that are present in the leaves of the query tree.

Returns:
The tuple count

Implements ca.uqac.dim.ddb.Relation.


Member Data Documentation

String ca.uqac.dim.ddb.Table.m_name [protected]

The documentation for this class was generated from the following file: