simpledb
Class TupleIterator

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

public class TupleIterator
extends java.lang.Object
implements DbIterator

Implements a DbIterator by wrapping an Iterable.


Field Summary
(package private)  java.util.Iterator<Tuple> i
           
(package private)  TupleDesc td
           
(package private)  java.lang.Iterable<Tuple> tuples
           
 
Constructor Summary
TupleIterator(TupleDesc td, java.lang.Iterable<Tuple> tuples)
          Constructs an iterator from the specified Iterable, and the specified descriptor.
 
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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

i

java.util.Iterator<Tuple> i

td

TupleDesc td

tuples

java.lang.Iterable<Tuple> tuples
Constructor Detail

TupleIterator

public TupleIterator(TupleDesc td,
                     java.lang.Iterable<Tuple> tuples)
Constructs an iterator from the specified Iterable, and the specified descriptor.

Parameters:
tuples - The set of tuples to iterate over
Method Detail

open

public void open()
Description copied from interface: DbIterator
Opens the iterator. This must be called before any of the other methods.

Specified by:
open in interface DbIterator

hasNext

public boolean hasNext()
Description copied from interface: DbIterator
Returns true if the iterator has more tuples.

Specified by:
hasNext in interface DbIterator
Returns:
true f the iterator has more tuples.

next

public Tuple next()
Description copied from interface: DbIterator
Returns the next tuple from the operator (typically implementing by reading from a child operator or an access method).

Specified by:
next in interface DbIterator
Returns:
the next tuple in the iteration.

rewind

public void rewind()
Description copied from interface: DbIterator
Resets the iterator to the start.

Specified by:
rewind in interface DbIterator

getTupleDesc

public TupleDesc getTupleDesc()
Description copied from interface: DbIterator
Returns the TupleDesc associated with this DbIterator.

Specified by:
getTupleDesc in interface DbIterator
Returns:
the TupleDesc associated with this DbIterator.

close

public void close()
Description copied from interface: DbIterator
Closes the iterator. When the iterator is closed, calling next(), hasNext(), or rewind() should fail by throwing IllegalStateException.

Specified by:
close in interface DbIterator