Turtle DB
A mini DDBMS
ca.uqac.dim.ddb.Relation Class Reference
Inheritance diagram for ca.uqac.dim.ddb.Relation:
ca.uqac.dim.ddb.NAryRelation ca.uqac.dim.ddb.Table ca.uqac.dim.ddb.UnaryRelation ca.uqac.dim.ddb.Intersection ca.uqac.dim.ddb.Union ca.uqac.dim.ddb.Projection ca.uqac.dim.ddb.Selection ca.uqac.dim.ddb.VariableTable

List of all members.

Public Member Functions

void reset ()
abstract Schema getSchema ()
 Relation ()
final boolean hasNext ()
final Tuple next ()
final int getDegree ()
String toString ()
void remove ()
abstract void accept (QueryVisitor v) throws QueryVisitor.VisitorException
int getCardinality ()
abstract int tupleCount ()
boolean contains (Tuple tup)

Protected Member Functions

abstract Tuple internalNext ()

Protected Attributes

List< Tuplem_outputTuples
Tuple m_nextTuple
boolean m_internalNextCalled

Detailed Description

A relation is implemented as a map from a set of tuples (the relation's key) to a set of tuples

Author:
sylvain

Constructor & Destructor Documentation

Empty constructor. Should only be called from children's constructors.


Member Function Documentation

Determines if a relation contains a given tuple. Warning #1: this implementation is inefficient, as it enumerates all tuples until found. Warning #2: using contains resets any undergoing enumeration made on the relation.

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

Reimplemented in ca.uqac.dim.ddb.Table.

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 in ca.uqac.dim.ddb.Table.

A relation's degree is the size of its schema.

Returns:
The relation's degree
abstract Tuple ca.uqac.dim.ddb.Relation.internalNext ( ) [protected, pure virtual]

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

Implemented in ca.uqac.dim.ddb.Table, ca.uqac.dim.ddb.Projection, ca.uqac.dim.ddb.Selection, ca.uqac.dim.ddb.VariableTable, ca.uqac.dim.ddb.Intersection, and ca.uqac.dim.ddb.Union.

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

Reimplemented in ca.uqac.dim.ddb.Table, ca.uqac.dim.ddb.Union, and ca.uqac.dim.ddb.UnaryRelation.

Pretty-prints a relation to a string

abstract int ca.uqac.dim.ddb.Relation.tupleCount ( ) [pure 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.

Returns:
The tuple count

Implemented in ca.uqac.dim.ddb.Table, ca.uqac.dim.ddb.VariableTable, ca.uqac.dim.ddb.NAryRelation, and ca.uqac.dim.ddb.UnaryRelation.


Member Data Documentation


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