simpledb
Class SeqScan

java.lang.Object
  extended by simpledb.SeqScan
All Implemented Interfaces:
DbIterator

public class SeqScan
extends java.lang.Object
implements DbIterator

SeqScan is an implementation of a sequential scan access method that reads each tuple of a table in no particular order (e.g., as they are laid out on disk).


Constructor Summary
SeqScan(TransactionId tid, int tableid, java.lang.String tableAlias)
          Constructor.
 
Method Summary
 void close()
          Closes the sequential scan.
 TupleDesc getTupleDesc()
          Implementation of DbIterator.getTupleDesc method.
 boolean hasNext()
           
 Tuple next()
          Implementation of DbIterator.getNext method.
 void open()
          Opens this sequential scan.
 void rewind()
          Rewinds the sequential back to the first record.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SeqScan

public SeqScan(TransactionId tid,
               int tableid,
               java.lang.String tableAlias)
Constructor. Creates a sequential scan over the specified table as a part of the specified transaction.

Parameters:
tid - The transaction this scan is running as a part of.
tableid - the table to scan.
tableAlias - the alias of this table (needed by the parser); the returned tupleDesc should have fields with name tableAlias.fieldName (note: this class is not responsible for handling a case where tableAlias or fieldName are null. It shouldn't crash if they are, but the resulting name can be null.fieldName, tableAlias.null, or null.null).
Method Detail

open

public void open()
          throws DbException,
                 TransactionAbortedException
Opens this sequential scan. Needs to be called before getNext().

Specified by:
open in interface DbIterator
Throws:
DbException - when there are problems opening/accessing the database.
TransactionAbortedException

getTupleDesc

public TupleDesc getTupleDesc()
Implementation of DbIterator.getTupleDesc method. Should return a tupleDesc with field names from the underlying HeapFile with field names prefaced by the passed in tableAlias string

Specified by:
getTupleDesc in interface DbIterator

hasNext

public boolean hasNext()
                throws TransactionAbortedException,
                       DbException
Specified by:
hasNext in interface DbIterator
Returns:
true if the iterator has more items.
Throws:
TransactionAbortedException
DbException

next

public Tuple next()
           throws java.util.NoSuchElementException,
                  TransactionAbortedException,
                  DbException
Implementation of DbIterator.getNext method. Return the next tuple in the scan, or null if there are no more tuples.

Specified by:
next in interface DbIterator
Returns:
The next tuple in the iterator, or null if there are no more tuples.
Throws:
java.util.NoSuchElementException
TransactionAbortedException
DbException

close

public void close()
Closes the sequential scan.

Specified by:
close in interface DbIterator

rewind

public void rewind()
            throws DbException,
                   java.util.NoSuchElementException,
                   TransactionAbortedException
Rewinds the sequential back to the first record.

Specified by:
rewind in interface DbIterator
Throws:
DbException - When rewind is unsupported.
java.util.NoSuchElementException
TransactionAbortedException