simpledb
Interface DbIterator

All Known Implementing Classes:
SeqScan, TupleIterator

public interface DbIterator

DbIterator is the iterator interface that all SimpleDB operators should implement. If the iterator is not open, none of the methods should work, and should throw an IllegalStateException. In addition to any resource allocation/deallocation, an open method should call any child iterator open methods, and in a close method, an iterator should call its children's close methods.


Method Summary
 void close()
          Closes the iterator.
 TupleDesc getTupleDesc()
          Returns the TupleDesc associated with this DbIterator.
 boolean hasNext()
          Returns true if the iterator has more tuples.
 Tuple next()
          Returns the next tuple from the operator (typically implementing by reading from a child operator or an access method).
 void open()
          Opens the iterator.
 void rewind()
          Resets the iterator to the start.
 

Method Detail

open

void open()
          throws DbException,
                 TransactionAbortedException
Opens the iterator. This must be called before any of the other methods.

Throws:
DbException - when there are problems opening/accessing the database.
TransactionAbortedException

hasNext

boolean hasNext()
                throws DbException,
                       TransactionAbortedException
Returns true if the iterator has more tuples.

Returns:
true f the iterator has more tuples.
Throws:
java.lang.IllegalStateException - If the iterator has not been opened
DbException
TransactionAbortedException

next

Tuple next()
           throws DbException,
                  TransactionAbortedException,
                  java.util.NoSuchElementException
Returns the next tuple from the operator (typically implementing by reading from a child operator or an access method).

Returns:
the next tuple in the iteration.
Throws:
java.util.NoSuchElementException - if there are no more tuples.
java.lang.IllegalStateException - If the iterator has not been opened
DbException
TransactionAbortedException

rewind

void rewind()
            throws DbException,
                   TransactionAbortedException
Resets the iterator to the start.

Throws:
DbException - when rewind is unsupported.
java.lang.IllegalStateException - If the iterator has not been opened
TransactionAbortedException

getTupleDesc

TupleDesc getTupleDesc()
Returns the TupleDesc associated with this DbIterator.

Returns:
the TupleDesc associated with this DbIterator.

close

void close()
Closes the iterator. When the iterator is closed, calling next(), hasNext(), or rewind() should fail by throwing IllegalStateException.