TurtleDB
A mini distributed database system
|
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< Tuple > | tupleIterator () |
Protected Attributes | |
List< Tuple > | m_tuples |
Schema | m_schema |
int | m_cursor |
String | m_name |
Package Functions | |
Table () | |
Table (String s) | |
Table (Schema sch) |
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.
Definition at line 35 of file Table.java.
ca.uqac.dim.turtledb.Table.Table | ( | ) | [package] |
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.
ca.uqac.dim.turtledb.Table.Table | ( | Schema | sch | ) | [package] |
Creates an empty table with given schema
sch | The table's schema |
Definition at line 86 of file Table.java.
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.
RelationIterator ca.uqac.dim.turtledb.Table.cacheIterator | ( | ) | [virtual] |
Returns an iterator over tuples of the relation
Implements ca.uqac.dim.turtledb.Relation.
Definition at line 263 of file Table.java.
boolean ca.uqac.dim.turtledb.Table.contains | ( | Tuple | tup | ) |
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.
tup | The tuple to look for |
Reimplemented from ca.uqac.dim.turtledb.Relation.
Definition at line 197 of file Table.java.
void ca.uqac.dim.turtledb.Table.copy | ( | Relation | r | ) |
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.
r | The 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.
Reimplemented from ca.uqac.dim.turtledb.Relation.
Definition at line 181 of file Table.java.
String ca.uqac.dim.turtledb.Table.getName | ( | ) |
Schema ca.uqac.dim.turtledb.Table.getSchema | ( | ) | [virtual] |
Returns the relation's schema
Implements ca.uqac.dim.turtledb.Relation.
Definition at line 113 of file Table.java.
final boolean ca.uqac.dim.turtledb.Table.isLeaf | ( | ) |
Determines if a given operator is at the leaf of the query tree. Only instances of Table and VariableTable may be leaves.
Reimplemented from ca.uqac.dim.turtledb.Relation.
Definition at line 210 of file Table.java.
void ca.uqac.dim.turtledb.Table.put | ( | Tuple | t | ) |
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.
t | The 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.
tuples | The 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.
name | The table's name |
Definition at line 75 of file Table.java.
void ca.uqac.dim.turtledb.Table.setSchema | ( | Schema | sch | ) | [protected] |
Returns an iterator over tuples of the relation
Implements ca.uqac.dim.turtledb.Relation.
Definition at line 216 of file Table.java.
int ca.uqac.dim.turtledb.Table.tupleCount | ( | ) | [virtual] |
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.
Implements ca.uqac.dim.turtledb.Relation.
Definition at line 204 of file Table.java.
Iterator<Tuple> ca.uqac.dim.turtledb.Table.tupleIterator | ( | ) | [protected] |
Definition at line 245 of file Table.java.
int ca.uqac.dim.turtledb.Table.m_cursor [protected] |
Definition at line 39 of file Table.java.
String ca.uqac.dim.turtledb.Table.m_name [protected] |
Definition at line 40 of file Table.java.
Schema ca.uqac.dim.turtledb.Table.m_schema [protected] |
Definition at line 38 of file Table.java.
List<Tuple> ca.uqac.dim.turtledb.Table.m_tuples [protected] |
Definition at line 37 of file Table.java.