public class TableIterator extends Object
Constructor and Description |
---|
TableIterator(SQLStatement stmt,
Table table,
boolean evalWhere)
Constructs a TableIterator object for the subset of the specified
table that is defined by the given SQLStatement.
|
Modifier and Type | Method and Description |
---|---|
void |
close()
Closes the iterator, which closes any BDB handles that it is using.
|
boolean |
first()
Positions the iterator on the first tuple in the relation, without
taking the a WHERE clause (if any) into effect.
|
Column |
getColumn(int colIndex)
Gets the column at the specified index in the relation that
this iterator iterates over.
|
Object |
getColumnVal(int colIndex)
Gets the value of the column at the specified index in the row
on which this iterator is currently positioned.
|
boolean |
next()
Advances the iterator to the next tuple in the relation.
|
int |
numColumns()
Gets the number of columns in the table being iterated over
|
int |
numTuples()
Gets the number of tuples that the iterator has visited.
|
void |
printAll(PrintStream out)
Iterates over all rows in the relation and prints them to the
specified PrintStream (e.g., System.out).
|
public TableIterator(SQLStatement stmt, Table table, boolean evalWhere) throws DatabaseException
stmt
- the SQL statement that defines the subset of the tabletable
- the table to iterate overevalWhere
- should the WHERE clause in stmt be evaluated by this
iterator? If this iterator is being used by a higher-level
iterator, then we can specify false so that the WHERE clause
will not be evaluated at this level.IllegalStateException
- if the specified Table object has not
already been openedDatabaseException
- if Berkeley DB encounters a problem
while accessing one of the underlying database(s)public void close() throws DatabaseException
DatabaseException
- if Berkeley DB encounters a problem
while closing a handlepublic boolean first() throws DeadlockException, DatabaseException
DeadlockException
- if deadlock occurs while accessing the
underlying BDB database(s)DatabaseException
- if Berkeley DB encounters another problem
while accessing the underlying database(s)public boolean next() throws DeadlockException, DatabaseException
DeadlockException
- if deadlock occurs while accessing the
underlying BDB database(s)DatabaseException
- if Berkeley DB encounters another problem
while accessing the underlying database(s)public Column getColumn(int colIndex)
IndexOutOfBoundsException
- if the specified index is invalidpublic Object getColumnVal(int colIndex)
IllegalStateException
- if the iterator has not yet been
been positioned on a tuple using first() or next()IndexOutOfBoundsException
- if the specified index is invalidpublic int numTuples()
public int numColumns()
public void printAll(PrintStream out) throws DeadlockException, DatabaseException
DeadlockException
- if deadlock occurs while accessing the
underlying BDB database(s)DatabaseException
- if Berkeley DB encounters another problem
while accessing the underlying database(s)