com.bigdata.service.ndx
Class RawDataServiceTupleIterator<E>

java.lang.Object
  extended by com.bigdata.btree.AbstractChunkedTupleIterator<E>
      extended by com.bigdata.service.ndx.RawDataServiceTupleIterator<E>
All Implemented Interfaces:
ITupleIterator<E>, Iterator<ITuple<E>>
Direct Known Subclasses:
DataServiceTupleIterator

public class RawDataServiceTupleIterator<E>
extends AbstractChunkedTupleIterator<E>

Class supports range query across against an unpartitioned index on an IDataService but DOES NOT handle index partition splits, moves or joins.

Note: This class supports caching of the remote metadata index, which does not use index partitions, by the AbstractDistributedFederation and also supports the LocalDataServiceFederation.

Version:
$Id: RawDataServiceTupleIterator.java 2265 2009-10-26 12:51:06Z thompsonbry $
Author:
Bryan Thompson
TODO:
write tests for read-consistent.

Field Summary
protected  IDataService dataService
          The data service for the index.
static String ERR_NO_KEYS
          Error message used by #getKey() when the iterator was not provisioned to request keys from the data service.
static String ERR_NO_VALS
          Error message used by #getValue() when the iterator was not provisioned to request values from the data service.
 String name
          The name of the index partition on which the range query is being performed.
 
Fields inherited from class com.bigdata.btree.AbstractChunkedTupleIterator
capacity, DEBUG, exhausted, filter, flags, fromKey, INFO, lastVisited, lastVisitedKeyInPriorResultSet, log, nqueries, nvisited, rset, toKey
 
Constructor Summary
RawDataServiceTupleIterator(IDataService dataService, String name, long timestamp, boolean readConsistent, byte[] fromKey, byte[] toKey, int capacity, int flags, IFilterConstructor filter)
           
 
Method Summary
protected  void deleteBehind(int n, Iterator<byte[]> itr)
          Batch delete the index entries identified by keys and clear the list.
protected  void deleteLast(byte[] key)
          Delete the index entry identified by key.
protected  boolean getReadConsistent()
          When true the AbstractChunkedTupleIterator.getCommitTime() will be used to ensure that AbstractChunkedTupleIterator.continuationQuery()s run against the same commit point for the local index partition thereby producing a read consistent view even when the iterator is ITx.READ_COMMITTED.
protected  ResultSet getResultSet(long timestamp, byte[] fromKey, byte[] toKey, int capacity, int flags, IFilterConstructor filter)
          Atomic operation caches a chunk of results from an IDataService.
protected  long getTimestamp()
          The timestamp for the operation as specified by the ctor (this is used for remote index queries but when running against a local index).
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, next, rangeQuery, remove
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ERR_NO_KEYS

public static final transient String ERR_NO_KEYS
Error message used by #getKey() when the iterator was not provisioned to request keys from the data service.

See Also:
Constant Field Values

ERR_NO_VALS

public static final transient String ERR_NO_VALS
Error message used by #getValue() when the iterator was not provisioned to request values from the data service.

See Also:
Constant Field Values

dataService

protected final IDataService dataService
The data service for the index.

Note: Be careful when using this field since you take on responsibilty for handling index partition splits, joins, and moves!

TODO:
this should failover if a data service dies. we need the logical data service UUID for that and we need to have (or discover) the service that maps logical data service UUIDs to physical data service UUIDs

name

public final String name
The name of the index partition on which the range query is being performed.

Constructor Detail

RawDataServiceTupleIterator

public RawDataServiceTupleIterator(IDataService dataService,
                                   String name,
                                   long timestamp,
                                   boolean readConsistent,
                                   byte[] fromKey,
                                   byte[] toKey,
                                   int capacity,
                                   int flags,
                                   IFilterConstructor filter)
Parameters:
dataService - The data service on which the index resides.
name - The name of the index partition on that data service.
timestamp - The timestamp used for the reads.
readConsistent - This option is only available for ITx.READ_COMMITTED. When true, the first read will be against the most recent commit point on the database and any continuation queries will be against the same commit point. When false, each read will be against the most recent commit point (so the data can be drawn from multiple commit points if there are concurrent commits).

The readConsistent option is a tweak available only at this low level for the RawDataServiceTupleIterator. It avoids a possible RMI to obtain the most recent global commit point using IIndexStore.getLastCommitTime() in favor of using the most recent commit point on the index partition at the time that the query is actually executed. If you are reading against a scale-out index, then similar effects are obtained by choosing either ITx.READ_COMMITTED or IIndexStore.getLastCommitTime(). See ClientIndexView and PartitionedTupleIterator.

fromKey -
toKey -
capacity -
flags -
filter -
Method Detail

getResultSet

protected ResultSet getResultSet(long timestamp,
                                 byte[] fromKey,
                                 byte[] toKey,
                                 int capacity,
                                 int flags,
                                 IFilterConstructor filter)
Atomic operation caches a chunk of results from an IDataService.

Note: This uses the timestamp specified by the caller NOT the timestamp value stored by this class. This allows us to have read-consistent semantics if desired for ITx.UNISOLATED or ITx.READ_COMMITTED operations.

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

deleteBehind

protected void deleteBehind(int n,
                            Iterator<byte[]> itr)
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.
itr - 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 final long getTimestamp()
Description copied from class: AbstractChunkedTupleIterator
The timestamp for the operation as specified by the ctor (this is used for remote index queries but when running against a local index).

Specified by:
getTimestamp in class AbstractChunkedTupleIterator<E>

getReadConsistent

protected final boolean getReadConsistent()
Description copied from class: AbstractChunkedTupleIterator
When true the AbstractChunkedTupleIterator.getCommitTime() will be used to ensure that AbstractChunkedTupleIterator.continuationQuery()s run against the same commit point for the local index partition thereby producing a read consistent view even when the iterator is ITx.READ_COMMITTED. When false AbstractChunkedTupleIterator.continuationQuery()s will use whatever value is returned by AbstractChunkedTupleIterator.getTimestamp(). Read-consistent semantics for a partitioned index are achieved using the timestamp returned by IIndexStore.getLastCommitTime() rather than ITx.READ_COMMITTED.

Specified by:
getReadConsistent in class AbstractChunkedTupleIterator<E>


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