|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.accumulo.examples.wikisearch.iterator.AbstractEvaluatingIterator
public abstract class AbstractEvaluatingIterator
This iterator aggregates rows together using the specified key comparator. Subclasses will provide their own implementation of fillMap which will fill the supplied EventFields object with field names (key) and field values (value). After all fields have been put into the aggregated object (by aggregating all columns with the same key), the EventFields object will be compared against the supplied expression. If the expression returns true, then the return key and return value can be retrieved via getTopKey() and getTopValue(). Optionally, the caller can set an expression (field operator value) that should not be evaluated against the event. For example, if the query is "A == 'foo' and B == 'bar'", but for some reason B may not be in the data, then setting the UNEVALUATED_EXPRESSIONS option to "B == 'bar'" will allow the events to be evaluated against the remainder of the expression and still return as true. By default this iterator will return all Events in the shard. If the START_DATE and END_DATE are specified, then this iterator will evaluate the timestamp of the key against the start and end dates. If the event date is not within the range of start to end, then it is skipped. This iterator will return up the stack an EventFields object serialized using Kryo in the cell Value.
Nested Class Summary |
---|
Nested classes/interfaces inherited from interface org.apache.accumulo.core.iterators.OptionDescriber |
---|
OptionDescriber.IteratorOptions |
Field Summary | |
---|---|
protected SortedKeyValueIterator<Key,Value> |
iterator
|
protected static byte[] |
NULL_BYTE
|
static String |
QUERY_OPTION
|
static String |
UNEVALUTED_EXPRESSIONS
|
Constructor Summary | |
---|---|
|
AbstractEvaluatingIterator()
|
protected |
AbstractEvaluatingIterator(AbstractEvaluatingIterator other,
IteratorEnvironment env)
|
Method Summary | |
---|---|
OptionDescriber.IteratorOptions |
describeOptions()
Gets an iterator options object that contains information needed to configure this iterator. |
abstract void |
fillMap(EventFields event,
Key key,
Value value)
Implementations will need to fill the map with field visibilities, names, and values. |
abstract PartialKey |
getKeyComparator()
Implementations will return the PartialKey value to use for comparing keys for aggregating events |
String |
getQueryExpression()
|
abstract Key |
getReturnKey(Key k)
When the query expression evaluates to true against the event, the event fields will be serialized into the Value and returned up the iterator stack. |
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. |
abstract boolean |
isKeyAccepted(Key key)
Provides the ability to skip this key and all of the following ones that match using the comparator. |
void |
next()
Advances to the next K,V pair. |
void |
reset()
Reset state. |
void |
seek(Range range,
Collection<ByteSequence> columnFamilies,
boolean inclusive)
Seeks to the first key in the Range, restricting the resulting K,V pairs to those with the specified columns. |
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 |
Methods inherited from interface org.apache.accumulo.core.iterators.SortedKeyValueIterator |
---|
deepCopy |
Field Detail |
---|
protected static final byte[] NULL_BYTE
public static final String QUERY_OPTION
public static final String UNEVALUTED_EXPRESSIONS
protected SortedKeyValueIterator<Key,Value> iterator
Constructor Detail |
---|
protected AbstractEvaluatingIterator(AbstractEvaluatingIterator other, IteratorEnvironment env)
public AbstractEvaluatingIterator()
Method Detail |
---|
public abstract PartialKey getKeyComparator()
public abstract Key getReturnKey(Key k) throws Exception
k
-
Exception
public abstract void fillMap(EventFields event, Key key, Value value) throws Exception
event
- Multimap of event names and fields.key
- current Keyvalue
- current Value
Exception
public abstract boolean isKeyAccepted(Key key) throws IOException
key
-
IOException
public void reset()
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 next() throws IOException
SortedKeyValueIterator
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
SortedKeyValueIterator
SortedKeyValueIterator.init(org.apache.accumulo.core.iterators.SortedKeyValueIterator, java.util.Map, org.apache.accumulo.core.iterators.IteratorEnvironment)
is called.
Iterators that examine groups of adjacent key/value pairs (e.g. rows) to determine their top key and value should be sure that they properly handle a seek
to a key in the middle of such a group (e.g. the middle of a row). Even if the client always seeks to a range containing an entire group (a,c), the tablet
server could send back a batch of entries corresponding to (a,b], then reseek the iterator to range (b,c) when the scan is continued.
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 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 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
public String getQueryExpression()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |