org.apache.accumulo.examples.wikisearch.iterator
Class ReadAheadIterator
java.lang.Object
org.apache.accumulo.examples.wikisearch.iterator.ReadAheadIterator
- All Implemented Interfaces:
- OptionDescriber, SortedKeyValueIterator<Key,Value>
public class ReadAheadIterator
- extends Object
- implements SortedKeyValueIterator<Key,Value>, OptionDescriber
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!
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
QUEUE_SIZE
public static final String QUEUE_SIZE
- See Also:
- Constant Field Values
TIMEOUT
public static final String TIMEOUT
- See Also:
- Constant Field Values
ReadAheadIterator
protected ReadAheadIterator(ReadAheadIterator other,
IteratorEnvironment env)
ReadAheadIterator
public ReadAheadIterator()
deepCopy
public SortedKeyValueIterator<Key,Value> deepCopy(IteratorEnvironment env)
- Specified by:
deepCopy in interface SortedKeyValueIterator<Key,Value>
getTopKey
public Key getTopKey()
- Specified by:
getTopKey in interface SortedKeyValueIterator<Key,Value>
getTopValue
public Value getTopValue()
- Specified by:
getTopValue in interface SortedKeyValueIterator<Key,Value>
hasTop
public boolean hasTop()
- Specified by:
hasTop in interface SortedKeyValueIterator<Key,Value>
init
public void init(SortedKeyValueIterator<Key,Value> source,
Map<String,String> options,
IteratorEnvironment env)
throws IOException
- Specified by:
init in interface SortedKeyValueIterator<Key,Value>
- Throws:
IOException
next
public void next()
throws IOException
- Populate the key and value
- Specified by:
next in interface SortedKeyValueIterator<Key,Value>
- Throws:
IOException
seek
public void seek(Range range,
Collection<ByteSequence> columnFamilies,
boolean inclusive)
throws IOException
- Seek to the next matching cell and call next to populate the key and value.
- Specified by:
seek in interface SortedKeyValueIterator<Key,Value>
- Throws:
IOException
describeOptions
public OptionDescriber.IteratorOptions describeOptions()
- Specified by:
describeOptions in interface OptionDescriber
validateOptions
public boolean validateOptions(Map<String,String> options)
- Specified by:
validateOptions in interface OptionDescriber
Copyright © 2012 The Apache Software Foundation. All Rights Reserved.