com.bigdata.btree.view
Class FusedTupleCursor<E>

java.lang.Object
  extended by com.bigdata.btree.view.FusedTupleIterator<ITupleCursor<E>,E>
      extended by com.bigdata.btree.view.FusedTupleCursor<E>
All Implemented Interfaces:
ITupleCursor<E>, ITupleIterator<E>, Iterator<ITuple<E>>

public class FusedTupleCursor<E>
extends FusedTupleIterator<ITupleCursor<E>,E>
implements ITupleCursor<E>

Layers on the additional methods from the ITupleCursor interface.

Note: Both the public methods and the internal fields are strongly typed as ITupleCursors rather than ITupleIterators.

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

Field Summary
 
Fields inherited from class com.bigdata.btree.view.FusedTupleIterator
current, DEBUG, deleted, flags, INFO, lastVisited, log, n, sourceIterator, sourceTuple
 
Constructor Summary
FusedTupleCursor(int flags, boolean deleted, ITupleCursor<E>[] srcs, IIndex ndx)
           
 
Method Summary
protected  ITuple<E> consumeLookaheadTuple()
          Extended to make a copy of the key for each visited tuple.
 IIndex getIndex()
          The backing index being traversed by the ITupleCursor.
 boolean hasNext()
          Return true if there is another tuple that orders after the current cursor position in the natural order of the index and that lies within the optional constraints key-range on the cursor or on the index partition.
 boolean hasPrior()
          Note: The implementation of hasPrior() closes parallels the implementation of hasNext() in the base class.
 ITuple<E> prior()
          Position the cursor on the first visitable tuple ordered less than the current cursor position in the natural key order of the index and return that tuple.
 void remove()
          Delegates the operation to the source view (correct deletion requires that a delete marker for the tuple is written onto first source index rather than deleting the tuple from the source from which it was materialized).
 ITuple<E> seek(byte[] key)
          Positions the cursor on the specified key.
 ITuple<E> seek(Object key)
          Variant that first encodes the key using the object returned by IndexMetadata.getTupleSerializer() for the backing index.
 
Methods inherited from class com.bigdata.btree.view.FusedTupleIterator
clearCurrent, next
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.bigdata.btree.ITupleCursor
next
 

Constructor Detail

FusedTupleCursor

public FusedTupleCursor(int flags,
                        boolean deleted,
                        ITupleCursor<E>[] srcs,
                        IIndex ndx)
Parameters:
flags -
deleted -
srcs - The source iterators.
ndx - The FusedView from which the source iterators were drawn (required). Note that the semantics of remove() on a fused view require that the tuple is overwritten by a delete marker in the 1st index of the view.
Method Detail

getIndex

public final IIndex getIndex()
Description copied from interface: ITupleCursor
The backing index being traversed by the ITupleCursor.

Specified by:
getIndex in interface ITupleCursor<E>

hasNext

public boolean hasNext()
Description copied from interface: ITupleCursor
Return true if there is another tuple that orders after the current cursor position in the natural order of the index and that lies within the optional constraints key-range on the cursor or on the index partition.

Note: in order to maintain standard iterator semantics, this method will return true if the current cursor position is undefined and #first() would report the existence of a visitable tuple.

Specified by:
hasNext in interface ITupleCursor<E>
Specified by:
hasNext in interface Iterator<ITuple<E>>
Overrides:
hasNext in class FusedTupleIterator<ITupleCursor<E>,E>

hasPrior

public boolean hasPrior()
Note: The implementation of hasPrior() closes parallels the implementation of hasNext() in the base class.

Specified by:
hasPrior in interface ITupleCursor<E>

prior

public ITuple<E> prior()
Description copied from interface: ITupleCursor
Position the cursor on the first visitable tuple ordered less than the current cursor position in the natural key order of the index and return that tuple.

Note: in order to maintain semantics parallel to standard iterator semantics, this method will visit the #last() visitable tuple if the current cursor position is undefined.

Specified by:
prior in interface ITupleCursor<E>

seek

public ITuple<E> seek(byte[] key)
Description copied from interface: ITupleCursor
Positions the cursor on the specified key.

If there is a corresponding visitable tuple in the index then it is returned.

If there is no visitable tuple in the index for that key then null is returned. You can use ITupleCursor.prior() or ITupleCursor.next() to locate the first visitable tuple to either side of the cursor position.

The cursor position is updated to the specified key regardless of whether there is a visitable tuple in the index for that key.

Specified by:
seek in interface ITupleCursor<E>
Parameters:
key - The key (required).
Returns:
The tuple corresponding to key if it exists and is visitable in the index and null otherwise.

consumeLookaheadTuple

protected ITuple<E> consumeLookaheadTuple()
Extended to make a copy of the key for each visited tuple.

Overrides:
consumeLookaheadTuple in class FusedTupleIterator<ITupleCursor<E>,E>
Returns:
The FusedTupleIterator.current tuple.
See Also:
lastKeyBuffer

seek

public final ITuple<E> seek(Object key)
Description copied from interface: ITupleCursor
Variant that first encodes the key using the object returned by IndexMetadata.getTupleSerializer() for the backing index.

Specified by:
seek in interface ITupleCursor<E>
Parameters:
key - The key (required).
Returns:
The tuple corresponding to the encoded key if it exists and is visitable in the index and null otherwise.

remove

public void remove()
Delegates the operation to the source view (correct deletion requires that a delete marker for the tuple is written onto first source index rather than deleting the tuple from the source from which it was materialized).

Note: You must specify IRangeQuery.CURSOR in order for remove() to be supported.

Specified by:
remove in interface ITupleCursor<E>
Specified by:
remove in interface Iterator<ITuple<E>>
Overrides:
remove in class FusedTupleIterator<ITupleCursor<E>,E>


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