org.apache.hadoop.hbase.filter
Class FilterList

java.lang.Object
  extended by org.apache.hadoop.hbase.filter.FilterList
All Implemented Interfaces:
Filter, org.apache.hadoop.io.Writable

public class FilterList
extends Object
implements Filter

Implementation of Filter that represents an ordered List of Filters which will be evaluated with a specified boolean operator FilterList.Operator.MUST_PASS_ALL (!AND) or FilterList.Operator.MUST_PASS_ONE (!OR). Since you can use Filter Lists as children of Filter Lists, you can create a hierarchy of filters to be evaluated. Defaults to FilterList.Operator.MUST_PASS_ALL.

TODO: Fix creation of Configuration on serialization and deserialization.


Nested Class Summary
static class FilterList.Operator
          set operator
 
Nested classes/interfaces inherited from interface org.apache.hadoop.hbase.filter.Filter
Filter.ReturnCode
 
Constructor Summary
FilterList()
          Default constructor, filters nothing.
FilterList(FilterList.Operator operator)
          Constructor that takes an operator.
FilterList(FilterList.Operator operator, List<Filter> rowFilters)
          Constructor that takes a set of Filters and an operator.
FilterList(List<Filter> rowFilters)
          Constructor that takes a set of Filters.
 
Method Summary
 void addFilter(Filter filter)
          Add a filter.
 boolean filterAllRemaining()
          If this returns true, the scan will terminate.
 Filter.ReturnCode filterKeyValue(KeyValue v)
          A way to filter based on the column family, column qualifier and/or the column value.
 boolean filterRow()
          Last chance to veto row based on previous Filter.filterKeyValue(KeyValue) calls.
 void filterRow(List<KeyValue> kvs)
          Chance to alter the list of keyvalues to be submitted.
 boolean filterRowKey(byte[] rowKey, int offset, int length)
          Filters a row based on the row key.
 List<Filter> getFilters()
          Get the filters.
 KeyValue getNextKeyHint(KeyValue currentKV)
          If the filter returns the match code SEEK_NEXT_USING_HINT, then it should also tell which is the next key it must seek to.
 FilterList.Operator getOperator()
          Get the operator.
 boolean hasFilterRow()
           
 void readFields(DataInput in)
           
 void reset()
          Reset the state of the filter between rows.
 void write(DataOutput out)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FilterList

public FilterList()
Default constructor, filters nothing. Required though for RPC deserialization.


FilterList

public FilterList(List<Filter> rowFilters)
Constructor that takes a set of Filters. The default operator MUST_PASS_ALL is assumed.

Parameters:
rowFilters - list of filters

FilterList

public FilterList(FilterList.Operator operator)
Constructor that takes an operator.

Parameters:
operator - Operator to process filter set with.

FilterList

public FilterList(FilterList.Operator operator,
                  List<Filter> rowFilters)
Constructor that takes a set of Filters and an operator.

Parameters:
operator - Operator to process filter set with.
rowFilters - Set of row filters.
Method Detail

getOperator

public FilterList.Operator getOperator()
Get the operator.

Returns:
operator

getFilters

public List<Filter> getFilters()
Get the filters.

Returns:
filters

addFilter

public void addFilter(Filter filter)
Add a filter.

Parameters:
filter - another filter

reset

public void reset()
Description copied from interface: Filter
Reset the state of the filter between rows.

Specified by:
reset in interface Filter

filterRowKey

public boolean filterRowKey(byte[] rowKey,
                            int offset,
                            int length)
Description copied from interface: Filter
Filters a row based on the row key. If this returns true, the entire row will be excluded. If false, each KeyValue in the row will be passed to Filter.filterKeyValue(KeyValue) below.

Specified by:
filterRowKey in interface Filter
Parameters:
rowKey - buffer containing row key
offset - offset into buffer where row key starts
length - length of the row key
Returns:
true, remove entire row, false, include the row (maybe).

filterAllRemaining

public boolean filterAllRemaining()
Description copied from interface: Filter
If this returns true, the scan will terminate.

Specified by:
filterAllRemaining in interface Filter
Returns:
true to end scan, false to continue.

filterKeyValue

public Filter.ReturnCode filterKeyValue(KeyValue v)
Description copied from interface: Filter
A way to filter based on the column family, column qualifier and/or the column value. Return code is described below. This allows filters to filter only certain number of columns, then terminate without matching ever column. If your filter returns ReturnCode.NEXT_ROW, it should return ReturnCode.NEXT_ROW until Filter.reset() is called just in case the caller calls for the next row.

Specified by:
filterKeyValue in interface Filter
Parameters:
v - the KeyValue in question
Returns:
code as described below
See Also:
Filter.ReturnCode

filterRow

public void filterRow(List<KeyValue> kvs)
Description copied from interface: Filter
Chance to alter the list of keyvalues to be submitted. Modifications to the list will carry on

Specified by:
filterRow in interface Filter
Parameters:
kvs - the list of keyvalues to be filtered

hasFilterRow

public boolean hasFilterRow()
Specified by:
hasFilterRow in interface Filter
Returns:
True if this filter actively uses filterRow(List). Primarily used to check for conflicts with scans(such as scans that do not read a full row at a time)

filterRow

public boolean filterRow()
Description copied from interface: Filter
Last chance to veto row based on previous Filter.filterKeyValue(KeyValue) calls. The filter needs to retain state then return a particular value for this call if they wish to exclude a row if a certain column is missing (for example).

Specified by:
filterRow in interface Filter
Returns:
true to exclude row, false to include row.

readFields

public void readFields(DataInput in)
                throws IOException
Specified by:
readFields in interface org.apache.hadoop.io.Writable
Throws:
IOException

write

public void write(DataOutput out)
           throws IOException
Specified by:
write in interface org.apache.hadoop.io.Writable
Throws:
IOException

getNextKeyHint

public KeyValue getNextKeyHint(KeyValue currentKV)
Description copied from interface: Filter
If the filter returns the match code SEEK_NEXT_USING_HINT, then it should also tell which is the next key it must seek to. After receiving the match code SEEK_NEXT_USING_HINT, the QueryMatcher would call this function to find out which key it must next seek to.

Specified by:
getNextKeyHint in interface Filter
Returns:
KeyValue which must be next seeked. return null if the filter is not sure which key to seek to next.


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