TurtleDB
A mini distributed database system
ca.uqac.dim.turtledb.Table Class Reference
Inheritance diagram for ca.uqac.dim.turtledb.Table:
Collaboration diagram for ca.uqac.dim.turtledb.Table:

List of all members.

Classes

class  TableCacheIterator
class  TableStreamIterator

Public Member Functions

 Table (Relation r)
void setName (String name)
String getName ()
Schema getSchema ()
void put (Tuple t)
void putAll (Collection< Tuple > tuples)
void accept (QueryVisitor v) throws EmptyQueryVisitor.VisitorException
void copy (Relation r)
int getCardinality ()
boolean contains (Tuple tup)
int tupleCount ()
final boolean isLeaf ()
RelationStreamIterator streamIterator ()
RelationIterator cacheIterator ()

Protected Member Functions

void setSchema (Schema sch)
Iterator< TupletupleIterator ()

Protected Attributes

List< Tuplem_tuples
Schema m_schema
int m_cursor
String m_name

Package Functions

 Table ()
 Table (String s)
 Table (Schema sch)

Detailed Description

A Table is a list of tuples. Since the leaves of a relational query tree are always tables, it is the only Relation that actually holds data.

Internally, tables are implemented as a sorted linked list of tuples. Sorting is maintained at insertion of each tuple. Consquently, a tuple that is to be modified will be removed, changed, and re-inserted so that the global ordering of tuples is always respected.

Author:
sylvain

Definition at line 35 of file Table.java.


Constructor & Destructor Documentation

Empty constructor. Should only be called from another constructor.

Definition at line 45 of file Table.java.

ca.uqac.dim.turtledb.Table.Table ( String  s) [package]

Definition at line 52 of file Table.java.

Constructor by copy

Parameters:
r

Definition at line 62 of file Table.java.

Creates an empty table with given schema

Parameters:
schThe table's schema

Definition at line 86 of file Table.java.


Member Function Documentation

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

Implements ca.uqac.dim.turtledb.Relation.

Definition at line 157 of file Table.java.

Returns an iterator over tuples of the relation

Returns:

Implements ca.uqac.dim.turtledb.Relation.

Definition at line 263 of file Table.java.

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.turtledb.Relation.

Definition at line 197 of file Table.java.

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

Definition at line 169 of file Table.java.

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.turtledb.Relation.

Definition at line 181 of file Table.java.

Gives the table's name

Returns:
The table's name

Definition at line 96 of file Table.java.

Returns the relation's schema

Returns:
The schema

Implements ca.uqac.dim.turtledb.Relation.

Definition at line 113 of file Table.java.

Determines if a given operator is at the leaf of the query tree. Only instances of Table and VariableTable may be leaves.

Returns:

Reimplemented from ca.uqac.dim.turtledb.Relation.

Definition at line 210 of file Table.java.

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). This also affixes the table's name to each attribute, except if the table's name is the empty string.

The method put also ensures that the tuple is inserted at the correct location to keep the linked list sorted.

Parameters:
tThe tuple to add

Definition at line 130 of file Table.java.

void ca.uqac.dim.turtledb.Table.putAll ( Collection< Tuple tuples)

Adds a collection of tuples to the table. This is just the repeated application of put to every tuple in the collection.

Parameters:
tuplesThe tuples to add

Definition at line 148 of file Table.java.

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

Sets a name for the table. It is preferred to create a table with a name directly through the constructor, as using this method implies changing the table's name into every attribute of every tuple a posteriori.

Parameters:
nameThe table's name

Definition at line 75 of file Table.java.

void ca.uqac.dim.turtledb.Table.setSchema ( Schema  sch) [protected]

Sets the table's schema

Parameters:
schThe schema

Definition at line 105 of file Table.java.

Returns an iterator over tuples of the relation

Returns:

Implements ca.uqac.dim.turtledb.Relation.

Definition at line 216 of file Table.java.

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.turtledb.Relation.

Definition at line 204 of file Table.java.

Definition at line 245 of file Table.java.


Member Data Documentation

Definition at line 39 of file Table.java.

Definition at line 40 of file Table.java.

Definition at line 38 of file Table.java.

Definition at line 37 of file Table.java.


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