org.apache.accumulo.core.iterators.user
public class IntersectingIterator extends Object implements SortedKeyValueIterator<Key,Value>
seek(Range, Collection, boolean)
as it performs intersections over terms. Extending classes
should override the IntersectingIterator.TermSource.seekColfams
in their implementation's init(SortedKeyValueIterator, Map, IteratorEnvironment)
method.
README.shard in docs/examples shows an example of using the IntersectingIterator.Modifier and Type | Class and Description |
---|---|
static class |
IntersectingIterator.TermSource |
Modifier and Type | Field and Description |
---|---|
protected org.apache.hadoop.io.Text |
currentDocID |
protected org.apache.hadoop.io.Text |
currentPartition |
protected static org.apache.log4j.Logger |
log |
protected org.apache.hadoop.io.Text |
nullText |
protected IntersectingIterator.TermSource[] |
sources |
protected Key |
topKey |
protected Value |
value |
Constructor and Description |
---|
IntersectingIterator() |
Modifier and Type | Method and Description |
---|---|
void |
addSource(SortedKeyValueIterator<Key,Value> source,
IteratorEnvironment env,
org.apache.hadoop.io.Text term,
boolean notFlag) |
protected void |
advanceToIntersection() |
protected Key |
buildFollowingPartitionKey(Key key) |
protected Key |
buildKey(org.apache.hadoop.io.Text partition,
org.apache.hadoop.io.Text term) |
protected Key |
buildKey(org.apache.hadoop.io.Text partition,
org.apache.hadoop.io.Text term,
org.apache.hadoop.io.Text docID) |
protected static boolean[] |
decodeBooleans(String flags) |
protected static org.apache.hadoop.io.Text[] |
decodeColumns(String columns) |
SortedKeyValueIterator<Key,Value> |
deepCopy(IteratorEnvironment env)
Creates a deep copy of this iterator as though seek had not yet been called.
|
protected static String |
encodeBooleans(boolean[] flags) |
protected static String |
encodeColumns(org.apache.hadoop.io.Text[] columns) |
protected org.apache.hadoop.io.Text |
getDocID(Key key) |
protected org.apache.hadoop.io.Text |
getPartition(Key key) |
protected org.apache.hadoop.io.Text |
getTerm(Key key) |
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()
Advances to the next K,V pair.
|
void |
seek(Range range,
Collection<ByteSequence> seekColumnFamilies,
boolean inclusive)
Seeks to the first key in the Range, restricting the resulting K,V pairs to those with the specified columns.
|
static void |
setColumnFamilies(IteratorSetting cfg,
org.apache.hadoop.io.Text[] columns)
Encode the columns to be used when iterating.
|
static void |
setColumnFamilies(IteratorSetting cfg,
org.apache.hadoop.io.Text[] columns,
boolean[] notFlags)
Encode columns and NOT flags indicating which columns should be negated (docIDs will be excluded if matching negated columns, instead of included).
|
static String |
stringTopKey(SortedKeyValueIterator<Key,Value> iter) |
protected org.apache.hadoop.io.Text nullText
protected static final org.apache.log4j.Logger log
protected IntersectingIterator.TermSource[] sources
protected org.apache.hadoop.io.Text currentPartition
protected org.apache.hadoop.io.Text currentDocID
protected Key topKey
protected Value value
protected org.apache.hadoop.io.Text getPartition(Key key)
protected org.apache.hadoop.io.Text getTerm(Key key)
protected org.apache.hadoop.io.Text getDocID(Key key)
protected Key buildKey(org.apache.hadoop.io.Text partition, org.apache.hadoop.io.Text term)
protected Key buildKey(org.apache.hadoop.io.Text partition, org.apache.hadoop.io.Text term, org.apache.hadoop.io.Text docID)
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 next() throws IOException
SortedKeyValueIterator
next
in interface SortedKeyValueIterator<Key,Value>
IOException
- if an I/O error occurs.protected void advanceToIntersection() throws IOException
IOException
public static String stringTopKey(SortedKeyValueIterator<Key,Value> iter)
protected static String encodeColumns(org.apache.hadoop.io.Text[] columns)
protected static String encodeBooleans(boolean[] flags)
protected static org.apache.hadoop.io.Text[] decodeColumns(String columns)
protected static boolean[] decodeBooleans(String flags)
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 seek(Range range, Collection<ByteSequence> seekColumnFamilies, 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.
columnFamilies
is used, at the lowest level, to determine which data blocks inside of an RFile need to be opened for this iterator. This set of data
blocks is also the set of locality groups defined for the given table. If no columnFamilies are provided, the data blocks for all locality groups inside of
the correct RFile will be opened and seeked in an attempt to find the correct start key, regardless of the startKey in the range
.
In an Accumulo instance in which multiple locality groups exist for a table, it is important to ensure that columnFamilies
is properly set to the
minimum required column families to ensure that data from separate locality groups is not inadvertently read.seek
in interface SortedKeyValueIterator<Key,Value>
range
- Range of keys to iterate over.seekColumnFamilies
- 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 addSource(SortedKeyValueIterator<Key,Value> source, IteratorEnvironment env, org.apache.hadoop.io.Text term, boolean notFlag)
public static void setColumnFamilies(IteratorSetting cfg, org.apache.hadoop.io.Text[] columns)
public static void setColumnFamilies(IteratorSetting cfg, org.apache.hadoop.io.Text[] columns, boolean[] notFlags)
Copyright © 2014 Apache Accumulo Project. All Rights Reserved.