public class FilterList extends Object implements Filter
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.
FilterList.Operator.MUST_PASS_ALL
evaluates lazily: evaluation stops as soon as one filter does
not include the KeyValue.
FilterList.Operator.MUST_PASS_ONE
evaluates non-lazily: all filters are always evaluated.
FilterList.Operator.MUST_PASS_ALL
.
TODO: Fix creation of Configuration on serialization and deserialization.
Modifier and Type | Class and Description |
---|---|
static class |
FilterList.Operator
set operator
|
Filter.ReturnCode
Constructor and Description |
---|
FilterList()
Default constructor, filters nothing.
|
FilterList(Filter... rowFilters)
Constructor that takes a var arg number of
Filter s. |
FilterList(FilterList.Operator operator)
Constructor that takes an operator.
|
FilterList(FilterList.Operator operator,
Filter... rowFilters)
Constructor that takes a var arg number of
Filter s and an operator. |
FilterList(FilterList.Operator operator,
List<Filter> rowFilters)
Constructor that takes a set of
Filter s and an operator. |
FilterList(List<Filter> rowFilters)
Constructor that takes a set of
Filter s. |
Modifier and Type | Method and Description |
---|---|
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() |
boolean |
isFamilyEssential(byte[] name) |
void |
readFields(DataInput in) |
void |
reset()
Reset the state of the filter between rows.
|
String |
toString() |
protected String |
toString(int maxFilters) |
KeyValue |
transform(KeyValue v)
Give the filter a chance to transform the passed KeyValue.
|
void |
write(DataOutput out) |
public FilterList()
public FilterList(List<Filter> rowFilters)
Filter
s. The default operator
MUST_PASS_ALL is assumed.rowFilters
- list of filterspublic FilterList(Filter... rowFilters)
Filter
s. The fefault operator
MUST_PASS_ALL is assumed.rowFilters
- public FilterList(FilterList.Operator operator)
operator
- Operator to process filter set with.public FilterList(FilterList.Operator operator, List<Filter> rowFilters)
Filter
s and an operator.operator
- Operator to process filter set with.rowFilters
- Set of row filters.public FilterList(FilterList.Operator operator, Filter... rowFilters)
Filter
s and an operator.operator
- Operator to process filter set with.rowFilters
- Filters to usepublic FilterList.Operator getOperator()
public void addFilter(Filter filter)
filter
- another filterpublic void reset()
Filter
public boolean filterRowKey(byte[] rowKey, int offset, int length)
Filter
Filter.filterKeyValue(KeyValue)
below.filterRowKey
in interface Filter
rowKey
- buffer containing row keyoffset
- offset into buffer where row key startslength
- length of the row keypublic boolean filterAllRemaining()
Filter
filterAllRemaining
in interface Filter
public KeyValue transform(KeyValue v)
Filter
transform
in interface Filter
v
- the KeyValue in questionThe transformed KeyValue is what is eventually returned to the
client. Most filters will return the passed KeyValue unchanged.
,
for an example of a transformation.
public Filter.ReturnCode filterKeyValue(KeyValue v)
Filter
ReturnCode.NEXT_ROW
, it should return
ReturnCode.NEXT_ROW
until Filter.reset()
is called
just in case the caller calls for the next row.filterKeyValue
in interface Filter
v
- the KeyValue in questionFilter.ReturnCode
public void filterRow(List<KeyValue> kvs)
Filter
public boolean hasFilterRow()
hasFilterRow
in interface Filter
public boolean filterRow()
Filter
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).public void readFields(DataInput in) throws IOException
readFields
in interface org.apache.hadoop.io.Writable
IOException
public void write(DataOutput out) throws IOException
write
in interface org.apache.hadoop.io.Writable
IOException
public KeyValue getNextKeyHint(KeyValue currentKV)
Filter
getNextKeyHint
in interface Filter
public boolean isFamilyEssential(byte[] name)
protected String toString(int maxFilters)
Copyright © 2014 The Apache Software Foundation. All Rights Reserved.