com.bigdata.btree.filter
Class TupleFilter.Filterator

java.lang.Object
  extended by com.bigdata.btree.filter.TupleFilter.Filterator
Type Parameters:
E -
All Implemented Interfaces:
ITupleIterator<E>, Iterator<ITuple<E>>
Direct Known Subclasses:
TupleUpdater.Updaterator
Enclosing class:
TupleFilter<E>

protected class TupleFilter.Filterator
extends Object
implements ITupleIterator<E>

Implementation class knows how to avoid side-effects from the reuse of the same Tuple instance by the base ITupleIterator impls.

Version:
$Id: TupleFilter.java 2265 2009-10-26 12:51:06Z thompsonbry $
Author:
Bryan Thompson

Field Summary
protected  ITupleIterator<E> src
          The source iterator.
 
Constructor Summary
TupleFilter.Filterator(ITupleIterator<E> src)
           
 
Method Summary
protected  ITuple getNext()
          One step look ahead.
 boolean hasNext()
           
 ITuple<E> next()
          Advance the iterator and return the ITuple from which you can extract the data and metadata for next entry.
 void remove()
          Note: remove() is supported iff the source iterator is an ITupleCursor and the underlying AbstractBTree allows modification.
protected  void visit(ITuple<E> tuple)
          Hook for subclasses.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

src

protected final ITupleIterator<E> src
The source iterator.

Constructor Detail

TupleFilter.Filterator

public TupleFilter.Filterator(ITupleIterator<E> src)
Method Detail

hasNext

public boolean hasNext()
Specified by:
hasNext in interface Iterator<ITuple<E>>

next

public ITuple<E> next()
Description copied from interface: ITupleIterator
Advance the iterator and return the ITuple from which you can extract the data and metadata for next entry.

Note: An ITupleIterators will generally return the same ITuple reference on on each invocation of this method. The caller is responsible for copying out any data or metadata of interest before calling ITupleIterator.next() again. See TupleFilter which is aware of this and can be used to stack filters safely.

Specified by:
next in interface ITupleIterator<E>
Specified by:
next in interface Iterator<ITuple<E>>
Returns:
The ITuple containing the data and metadata for the current index entry.

visit

protected void visit(ITuple<E> tuple)
Hook for subclasses. This is invoked immediately before next() returns. The default implementation is a NOP.

Parameters:
tuple - The tuple that will be visited.

remove

public void remove()
Note: remove() is supported iff the source iterator is an ITupleCursor and the underlying AbstractBTree allows modification.

Note: The filter imposes a one-step lookahead means that invoking remove() on the source iterator would cause the wrong element to be removed from the source iterator. Therefore this operation is disabled unless the ITupleCursor. ITupleCursor is safe for traversal with concurrent modification, so we can just remove the key from the source index.

Note: An ITupleCursor can be requested either at the top-level or by specifying IRangeQuery.CURSOR to TupleFilter#TupleFilter(int).

Specified by:
remove in interface Iterator<ITuple<E>>
Throws:
UnsupportedOperationException - unless the source iterator is an ITupleCursor.

getNext

protected ITuple getNext()
One step look ahead.

Returns:
The next object to be visited.


Copyright © 2006-2009 SYSTAP, LLC. All Rights Reserved.