com.bigdata.btree
Class ChunkedLocalRangeIterator<E>

java.lang.Object
  extended by com.bigdata.btree.AbstractChunkedTupleIterator<E>
      extended by com.bigdata.btree.ChunkedLocalRangeIterator<E>
All Implemented Interfaces:
ITupleIterator<E>, Iterator<ITuple<E>>

public class ChunkedLocalRangeIterator<E>
extends AbstractChunkedTupleIterator<E>

Chunked range iterator running against a local index or index view.

Note: When IRangeQuery.REMOVEALL is specified without the IRangeQuery.CURSOR flag, the iterator will populate its buffers up to the capacity and then delete behind once the buffer is full or as soon as the iterator is exhausted. This approach works with the somewhat faster ITupleIterator construct. When the IRangeQuery.CURSOR flag is specified, we directly use the ITupleCursor interface.

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

Field Summary
protected  IIndex ndx
          The backing IIndex.
 
Fields inherited from class com.bigdata.btree.AbstractChunkedTupleIterator
capacity, DEBUG, ERR_NO_KEYS, ERR_NO_VALS, exhausted, filter, flags, fromKey, INFO, lastVisited, lastVisitedKeyInPriorResultSet, log, nqueries, nvisited, rset, toKey
 
Constructor Summary
ChunkedLocalRangeIterator(IIndex ndx, byte[] fromKey, byte[] toKey, int capacity, int flags, IFilterConstructor filter)
           
 
Method Summary
protected  void deleteBehind(int n, Iterator<byte[]> keys)
          Batch delete the index entries identified by keys and clear the list.
protected  void deleteLast(byte[] key)
          Delete the index entry identified by key.
 boolean getReadConsistent()
          Returns true since the read will be consistent (it reads against the same index object for each ResultSet) but the values returned by getTimestamp() and AbstractChunkedTupleIterator.getReadTime() are ignored by #getResultSet(long, byte[], byte[], int, int, ITupleFilter) (since it is reading against a local index object).
protected  ResultSet getResultSet(long timestamp, byte[] fromKey, byte[] toKey, int capacity, int flags, IFilterConstructor filter)
          Note: timestamp is ignored since we are reading against a local index object.
protected  long getTimestamp()
          Always returns 0L.
 ITuple<E> next()
          Visits the next tuple, queuing it for removal unless IRangeQuery.CURSOR was specified, in which case it is deleted immediately.
protected  IBlock readBlock(int sourceIndex, long addr)
          Return an object that may be used to read the block from the backing store per the contract for ITuple.readBlock(long)
 
Methods inherited from class com.bigdata.btree.AbstractChunkedTupleIterator
continuationQuery, deleteBehind, flush, getCommitTime, getDefaultCapacity, getQueryCount, getReadTime, getVisitedCount, hasNext, rangeQuery, remove
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ndx

protected final IIndex ndx
The backing IIndex.

Constructor Detail

ChunkedLocalRangeIterator

public ChunkedLocalRangeIterator(IIndex ndx,
                                 byte[] fromKey,
                                 byte[] toKey,
                                 int capacity,
                                 int flags,
                                 IFilterConstructor filter)
Parameters:
fromKey -
toKey -
capacity -
flags -
filter -
Method Detail

getResultSet

protected ResultSet getResultSet(long timestamp,
                                 byte[] fromKey,
                                 byte[] toKey,
                                 int capacity,
                                 int flags,
                                 IFilterConstructor filter)
Note: timestamp is ignored since we are reading against a local index object.

Specified by:
getResultSet in class AbstractChunkedTupleIterator<E>
Returns:

next

public ITuple<E> next()
Visits the next tuple, queuing it for removal unless IRangeQuery.CURSOR was specified, in which case it is deleted immediately.

Note: Queuing for removal is done only for the local index so that data service range iterators will do their deletes on the local index when this range iterator runs rather than buffering the keys and then sending back a batch delete to the index later (this would also make IRangeQuery.REMOVEALL non-atomic).

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

deleteBehind

protected void deleteBehind(int n,
                            Iterator<byte[]> keys)
Description copied from class: AbstractChunkedTupleIterator
Batch delete the index entries identified by keys and clear the list.

Specified by:
deleteBehind in class AbstractChunkedTupleIterator<E>
Parameters:
n - The #of keys to be deleted.
keys - The keys to be deleted.

deleteLast

protected void deleteLast(byte[] key)
Description copied from class: AbstractChunkedTupleIterator
Delete the index entry identified by key.

Specified by:
deleteLast in class AbstractChunkedTupleIterator<E>
Parameters:
key - A key.

readBlock

protected IBlock readBlock(int sourceIndex,
                           long addr)
Description copied from class: AbstractChunkedTupleIterator
Return an object that may be used to read the block from the backing store per the contract for ITuple.readBlock(long)

Specified by:
readBlock in class AbstractChunkedTupleIterator<E>
Parameters:
sourceIndex - The value from ITuple.getSourceIndex().
addr - The value supplied to ITuple.readBlock(long).

getTimestamp

protected long getTimestamp()
Always returns 0L. This value is ignored by #getResultSet(long, byte[], byte[], int, int, ITupleFilter).

Specified by:
getTimestamp in class AbstractChunkedTupleIterator<E>

getReadConsistent

public boolean getReadConsistent()
Returns true since the read will be consistent (it reads against the same index object for each ResultSet) but the values returned by getTimestamp() and AbstractChunkedTupleIterator.getReadTime() are ignored by #getResultSet(long, byte[], byte[], int, int, ITupleFilter) (since it is reading against a local index object).

Specified by:
getReadConsistent in class AbstractChunkedTupleIterator<E>


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