public class Table extends Relation
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.
| Modifier and Type | Class and Description |
|---|---|
protected class |
Table.TableCacheIterator |
protected class |
Table.TableStreamIterator |
| Modifier and Type | Field and Description |
|---|---|
protected int |
m_cursor |
protected java.lang.String |
m_name |
protected Schema |
m_schema |
protected java.util.List<Tuple> |
m_tuples |
m_streamingMode| Modifier and Type | Method and Description |
|---|---|
void |
accept(QueryVisitor v) |
RelationIterator |
cacheIterator()
Returns an iterator over tuples of the relation
|
boolean |
contains(Tuple tup)
Determines if a relation contains a given tuple.
|
void |
copy(Relation r)
Copies the contents of a relation into the current relation.
|
int |
getCardinality()
Computes the cardinality of a relation.
|
java.lang.String |
getName()
Gives the table's name
|
Schema |
getSchema()
Returns the relation's schema
|
boolean |
isLeaf()
Determines if a given operator is at the leaf of the
query tree.
|
void |
put(Tuple t)
Adds a new tuple to the table.
|
void |
putAll(java.util.Collection<Tuple> tuples)
Adds a collection of tuples to the table.
|
void |
setName(java.lang.String name)
Sets a name for the table.
|
protected void |
setSchema(Schema sch)
Sets the table's schema
|
RelationStreamIterator |
streamIterator()
Returns an iterator over tuples of the relation
|
int |
tupleCount()
Returns the number of actual tuples present in the query.
|
protected java.util.Iterator<Tuple> |
tupleIterator() |
getDegree, isFragment, iterator, setStreamingMode, toStringprotected java.util.List<Tuple> m_tuples
protected Schema m_schema
protected int m_cursor
protected java.lang.String m_name
public Table(Relation r)
r - public void setName(java.lang.String name)
name - The table's namepublic java.lang.String getName()
protected void setSchema(Schema sch)
sch - The schemapublic Schema getSchema()
Relationpublic void put(Tuple t)
The method put also ensures that the tuple is inserted at the correct location to keep the linked list sorted.
t - The tuple to addpublic void putAll(java.util.Collection<Tuple> tuples)
put to every tuple in
the collection.tuples - The tuples to addpublic void accept(QueryVisitor v) throws QueryVisitor.VisitorException
accept in class RelationQueryVisitor.VisitorExceptionpublic void copy(Relation r)
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 frompublic int getCardinality()
RelationTable (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.getCardinality in class Relationpublic boolean contains(Tuple tup)
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.public int tupleCount()
RelationtupleCount in class Relationpublic final boolean isLeaf()
RelationTable and
VariableTable may be leaves.public RelationStreamIterator streamIterator()
RelationstreamIterator in class Relationprotected java.util.Iterator<Tuple> tupleIterator()
public RelationIterator cacheIterator()
RelationcacheIterator in class RelationCopyright © Sylvain HallĂ©. All Rights Reserved.