|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.accumulo.examples.wikisearch.iterator.ReadAheadIterator
public class ReadAheadIterator
This iterator takes the source iterator (the one below it in the iterator stack) and puts it in a background thread. The background thread continues processing and fills a queue with the Keys and Values from the source iterator. When seek() is called on this iterator, it pauses the background thread, clears the queue, calls seek() on the source iterator, then resumes the thread filling the queue. Users of this iterator can set the queue size, default is five elements. Users must be aware of the potential for OutOfMemory errors when using this iterator with large queue sizes or large objects. This iterator copies the Key and Value from the source iterator and puts them into the queue. This iterator introduces some parallelism into the server side iterator stack. One use case for this would be when an iterator takes a relatively long time to process each K,V pair and causes the iterators above it to wait. By putting the longer running iterator in a background thread we should be able to achieve greater throughput. NOTE: Experimental!
Nested Class Summary |
---|
Nested classes/interfaces inherited from interface org.apache.accumulo.core.iterators.OptionDescriber |
---|
OptionDescriber.IteratorOptions |
Field Summary | |
---|---|
static String |
QUEUE_SIZE
|
static String |
TIMEOUT
|
Constructor Summary | |
---|---|
|
ReadAheadIterator()
|
protected |
ReadAheadIterator(ReadAheadIterator other,
IteratorEnvironment env)
|
Method Summary | |
---|---|
SortedKeyValueIterator<Key,Value> |
deepCopy(IteratorEnvironment env)
Creates a deep copy of this iterator as though seek had not yet been called. |
OptionDescriber.IteratorOptions |
describeOptions()
Gets an iterator options object that contains information needed to configure this iterator. |
Key |
getTopKey()
Returns top key. |
Value |
getTopValue()
Returns top value. |
boolean |
hasTop()
Returns true if the iterator has more elements. |
void |
init(SortedKeyValueIterator<Key,Value> source,
Map<String,String> options,
IteratorEnvironment env)
Initializes the iterator. |
void |
next()
Populate the key and value |
void |
seek(Range range,
Collection<ByteSequence> columnFamilies,
boolean inclusive)
Seek to the next matching cell and call next to populate the key and value. |
boolean |
validateOptions(Map<String,String> options)
Check to see if an options map contains all options required by an iterator and that the option values are in the expected formats. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final String QUEUE_SIZE
public static final String TIMEOUT
Constructor Detail |
---|
protected ReadAheadIterator(ReadAheadIterator other, IteratorEnvironment env)
public ReadAheadIterator()
Method Detail |
---|
public SortedKeyValueIterator<Key,Value> deepCopy(IteratorEnvironment env)
SortedKeyValueIterator
deepCopy
in interface SortedKeyValueIterator<Key,Value>
env
- IteratorEnvironment environment in which iterator is being run.
public Key getTopKey()
SortedKeyValueIterator
getTopKey
in interface SortedKeyValueIterator<Key,Value>
public Value getTopValue()
SortedKeyValueIterator
getTopValue
in interface SortedKeyValueIterator<Key,Value>
public boolean hasTop()
SortedKeyValueIterator
hasTop
in interface SortedKeyValueIterator<Key,Value>
public void init(SortedKeyValueIterator<Key,Value> source, Map<String,String> options, IteratorEnvironment env) throws IOException
SortedKeyValueIterator
init
in interface SortedKeyValueIterator<Key,Value>
source
- SortedKeyValueIterator source to read data from.options
- Map map of string option names to option values.env
- IteratorEnvironment environment in which iterator is being run.
IOException
- unused.public void next() throws IOException
next
in interface SortedKeyValueIterator<Key,Value>
IOException
- if an I/O error occurs.public void seek(Range range, Collection<ByteSequence> columnFamilies, boolean inclusive) throws IOException
seek
in interface SortedKeyValueIterator<Key,Value>
range
- Range of keys to iterate over.columnFamilies
- Collection of column families to include or exclude.inclusive
- boolean that indicates whether to include (true) or exclude (false) column families.
IOException
- if an I/O error occurs.public OptionDescriber.IteratorOptions describeOptions()
OptionDescriber
describeOptions
in interface OptionDescriber
public boolean validateOptions(Map<String,String> options)
OptionDescriber
validateOptions
in interface OptionDescriber
options
- a map of option names to option values
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |