org.apache.accumulo.examples.wikisearch.iterator
Class AbstractEvaluatingIterator
java.lang.Object
org.apache.accumulo.examples.wikisearch.iterator.AbstractEvaluatingIterator
- All Implemented Interfaces:
- OptionDescriber, SortedKeyValueIterator<Key,Value>
- Direct Known Subclasses:
- EvaluatingIterator
public abstract class AbstractEvaluatingIterator
- extends Object
- implements SortedKeyValueIterator<Key,Value>, OptionDescriber
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.
|
Method Summary |
OptionDescriber.IteratorOptions |
describeOptions()
|
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()
|
Value |
getTopValue()
|
boolean |
hasTop()
|
void |
init(SortedKeyValueIterator<Key,Value> source,
Map<String,String> options,
IteratorEnvironment env)
|
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()
|
void |
reset()
Reset state. |
void |
seek(Range range,
Collection<ByteSequence> columnFamilies,
boolean inclusive)
|
boolean |
validateOptions(Map<String,String> options)
|
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
NULL_BYTE
protected static final byte[] NULL_BYTE
QUERY_OPTION
public static final String QUERY_OPTION
- See Also:
- Constant Field Values
UNEVALUTED_EXPRESSIONS
public static final String UNEVALUTED_EXPRESSIONS
- See Also:
- Constant Field Values
iterator
protected SortedKeyValueIterator<Key,Value> iterator
AbstractEvaluatingIterator
protected AbstractEvaluatingIterator(AbstractEvaluatingIterator other,
IteratorEnvironment env)
AbstractEvaluatingIterator
public AbstractEvaluatingIterator()
getKeyComparator
public abstract PartialKey getKeyComparator()
- Implementations will return the PartialKey value to use for comparing keys for aggregating events
- Returns:
- the type of comparator to use
getReturnKey
public abstract Key getReturnKey(Key k)
throws Exception
- 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.
Implemenations will need to provide a key to be used with the event.
- Parameters:
k -
- Returns:
- the key that should be returned with the map of values.
- Throws:
Exception
fillMap
public abstract void fillMap(EventFields event,
Key key,
Value value)
throws Exception
- Implementations will need to fill the map with field visibilities, names, and values. When all fields have been aggregated the event will be evaluated
against the query expression.
- Parameters:
event - Multimap of event names and fields.key - current Keyvalue - current Value
- Throws:
Exception
isKeyAccepted
public abstract boolean isKeyAccepted(Key key)
throws IOException
- Provides the ability to skip this key and all of the following ones that match using the comparator.
- Parameters:
key -
- Returns:
- true if the key should be acted upon, otherwise false.
- Throws:
IOException
reset
public void reset()
- Reset state.
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>
next
public void next()
throws IOException
- Specified by:
next in interface SortedKeyValueIterator<Key,Value>
- Throws:
IOException
seek
public void seek(Range range,
Collection<ByteSequence> columnFamilies,
boolean inclusive)
throws IOException
- Specified by:
seek in interface SortedKeyValueIterator<Key,Value>
- Throws:
IOException
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
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
getQueryExpression
public String getQueryExpression()
Copyright © 2012 The Apache Software Foundation. All Rights Reserved.