org.apache.accumulo.examples.wikisearch.iterator
Class AndIterator

java.lang.Object
  extended by org.apache.accumulo.examples.wikisearch.iterator.AndIterator
All Implemented Interfaces:
SortedKeyValueIterator<Key,Value>

public class AndIterator
extends Object
implements SortedKeyValueIterator<Key,Value>


Nested Class Summary
protected static class AndIterator.TermSource
          Used in representing a Term that is intersected on.
 
Field Summary
static String columnFamiliesOptionName
           
protected  byte[] emptyByteArray
           
protected static org.apache.log4j.Logger log
           
static String notFlagsOptionName
           
protected  org.apache.hadoop.io.Text nullText
           
static String termValuesOptionName
           
protected  Value value
           
 
Constructor Summary
AndIterator()
          Empty default constructor
AndIterator(AndIterator other, IteratorEnvironment env)
           
 
Method Summary
 void addSource(SortedKeyValueIterator<Key,Value> source, IteratorEnvironment env, org.apache.hadoop.io.Text term, boolean notFlag)
           
 void addSource(SortedKeyValueIterator<Key,Value> source, IteratorEnvironment env, org.apache.hadoop.io.Text dataLocation, org.apache.hadoop.io.Text term, boolean notFlag)
           
protected  void advanceToIntersection()
           
protected  Key buildFollowingPartitionKey(Key key)
          Return the key that directly follows the given key
protected  Key buildKey(org.apache.hadoop.io.Text row, org.apache.hadoop.io.Text dataLocation)
          Build a key from the given row and dataLocation
protected  Key buildKey(org.apache.hadoop.io.Text row, org.apache.hadoop.io.Text dataLocation, org.apache.hadoop.io.Text term)
          Build a key from the given row, dataLocation, and term
static boolean[] decodeBooleans(String flags)
          Decode the encoded NOT flags into a boolean array
static org.apache.hadoop.io.Text[] decodeColumns(String columns)
          Decode the encoded columns into a Text array
static org.apache.hadoop.io.Text[] decodeTermValues(String terms)
          Decode the encoded terms into a Text array
 SortedKeyValueIterator<Key,Value> deepCopy(IteratorEnvironment env)
           
static String encodeBooleans(boolean[] flags)
          Encode an array of booleans denoted which columns are NOT'ed
static String encodeColumns(org.apache.hadoop.io.Text[] columns)
          Encode a Text array of all the columns to intersect on
static String encodeTermValues(org.apache.hadoop.io.Text[] terms)
          Encode a Text array of all of the terms to intersect on.
protected  org.apache.hadoop.io.Text getDataLocation(Key key)
          Returns the given key's dataLocation
protected  org.apache.hadoop.io.Text getDocID(Key key)
          Returns the given key's DocID
protected  org.apache.hadoop.io.Text getPartition(Key key)
           
protected  org.apache.hadoop.io.Text getTerm(Key key)
          Returns the given key's term
 Key getTopKey()
           
 Value getTopValue()
           
protected  String getUID(Key key)
          Returns the given key's UID
 boolean hasTop()
           
 void init(SortedKeyValueIterator<Key,Value> source, Map<String,String> options, IteratorEnvironment env)
           
 boolean jump(Key jumpKey)
           
 void next()
           
 void seek(Range range, Collection<ByteSequence> seekColumnFamilies, boolean inclusive)
           
static String stringTopKey(SortedKeyValueIterator<Key,Value> iter)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

protected static final org.apache.log4j.Logger log

nullText

protected org.apache.hadoop.io.Text nullText

emptyByteArray

protected final byte[] emptyByteArray

value

protected Value value

columnFamiliesOptionName

public static final String columnFamiliesOptionName
See Also:
Constant Field Values

termValuesOptionName

public static final String termValuesOptionName
See Also:
Constant Field Values

notFlagsOptionName

public static final String notFlagsOptionName
See Also:
Constant Field Values
Constructor Detail

AndIterator

public AndIterator()
Empty default constructor


AndIterator

public AndIterator(AndIterator other,
                   IteratorEnvironment env)
Method Detail

getPartition

protected org.apache.hadoop.io.Text getPartition(Key key)

getDataLocation

protected org.apache.hadoop.io.Text getDataLocation(Key key)
Returns the given key's dataLocation

Parameters:
key -
Returns:
The given key's dataLocation

getTerm

protected org.apache.hadoop.io.Text getTerm(Key key)
Returns the given key's term

Parameters:
key -
Returns:
The given key's term

getDocID

protected org.apache.hadoop.io.Text getDocID(Key key)
Returns the given key's DocID

Parameters:
key -
Returns:
The given key's DocID

getUID

protected String getUID(Key key)
Returns the given key's UID

Parameters:
key -
Returns:
The given key's UID

buildKey

protected Key buildKey(org.apache.hadoop.io.Text row,
                       org.apache.hadoop.io.Text dataLocation)
Build a key from the given row and dataLocation

Parameters:
row - The desired row
dataLocation - The desired dataLocation
Returns:
A Key object built from the given row and dataLocation.

buildKey

protected Key buildKey(org.apache.hadoop.io.Text row,
                       org.apache.hadoop.io.Text dataLocation,
                       org.apache.hadoop.io.Text term)
Build a key from the given row, dataLocation, and term

Parameters:
row - The desired row
dataLocation - The desired dataLocation
term - The desired term
Returns:
A Key object built from the given row, dataLocation, and term.

buildFollowingPartitionKey

protected Key buildFollowingPartitionKey(Key key)
Return the key that directly follows the given key

Parameters:
key - The key who will be directly before the returned key
Returns:
The key directly following the given key.

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>

next

public void next()
          throws IOException
Specified by:
next in interface SortedKeyValueIterator<Key,Value>
Throws:
IOException

advanceToIntersection

protected void advanceToIntersection()
                              throws IOException
Throws:
IOException

stringTopKey

public static String stringTopKey(SortedKeyValueIterator<Key,Value> iter)

encodeColumns

public static String encodeColumns(org.apache.hadoop.io.Text[] columns)
Encode a Text array of all the columns to intersect on

Parameters:
columns - The columns to be encoded
Returns:
A Base64 encoded string (using a \n delimiter) of all columns to intersect on.

encodeTermValues

public static String encodeTermValues(org.apache.hadoop.io.Text[] terms)
Encode a Text array of all of the terms to intersect on. The terms should match the columns in a one-to-one manner

Parameters:
terms - The terms to be encoded
Returns:
A Base64 encoded string (using a \n delimiter) of all terms to intersect on.

encodeBooleans

public static String encodeBooleans(boolean[] flags)
Encode an array of booleans denoted which columns are NOT'ed

Parameters:
flags - The array of NOTs
Returns:
A base64 encoded string of which columns are NOT'ed

decodeColumns

public static org.apache.hadoop.io.Text[] decodeColumns(String columns)
Decode the encoded columns into a Text array

Parameters:
columns - The Base64 encoded String of the columns
Returns:
A Text array of the decoded columns

decodeTermValues

public static org.apache.hadoop.io.Text[] decodeTermValues(String terms)
Decode the encoded terms into a Text array

Parameters:
terms - The Base64 encoded String of the terms
Returns:
A Text array of decoded terms.

decodeBooleans

public static boolean[] decodeBooleans(String flags)
Decode the encoded NOT flags into a boolean array

Parameters:
flags -
Returns:
A boolean array of decoded NOT flags

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

seek

public void seek(Range range,
                 Collection<ByteSequence> seekColumnFamilies,
                 boolean inclusive)
          throws IOException
Specified by:
seek in interface SortedKeyValueIterator<Key,Value>
Throws:
IOException

addSource

public void addSource(SortedKeyValueIterator<Key,Value> source,
                      IteratorEnvironment env,
                      org.apache.hadoop.io.Text term,
                      boolean notFlag)

addSource

public void addSource(SortedKeyValueIterator<Key,Value> source,
                      IteratorEnvironment env,
                      org.apache.hadoop.io.Text dataLocation,
                      org.apache.hadoop.io.Text term,
                      boolean notFlag)

jump

public boolean jump(Key jumpKey)
             throws IOException
Throws:
IOException


Copyright © 2012 The Apache Software Foundation. All Rights Reserved.