@InterfaceAudience.Public public class SingleColumnValueFilter extends org.apache.hadoop.hbase.filter.FilterBase
CompareOperator
operator
(equal, greater, not equal, etc), and either a byte [] value or a ByteArrayComparable.
If we have a byte [] value then we just do a lexicographic compare. For example, if passed value is 'b' and cell has 'a' and the compare operator is LESS, then we will filter out this cell (return true). If this is not sufficient (eg you want to deserialize a long and then compare it to a fixed long value), then you can pass in your own comparator instead.
You must also specify a family and qualifier. Only the value of this column will be tested. When
using this filter on a CellScanner
with specified inputs, the
column to be tested should also be added as input (otherwise the filter will regard the column as
missing).
To prevent the entire row from being emitted if the column is not found on a row, use
setFilterIfMissing(boolean)
. Otherwise, if the column is found, the entire row will be emitted
only if the value passes. If the value fails, the row will be filtered out.
In order to test values of previous versions (timestamps), set setLatestVersionOnly(boolean)
to
false. The default is true, meaning that only the latest version's value is tested and all
previous versions are ignored.
To filter based on the value of all scanned columns, use ValueFilter
.
Filter.ReturnCode
Modifier and Type | Field and Description |
---|---|
protected byte[] |
columnFamily |
protected byte[] |
columnQualifier |
protected ByteArrayComparable |
comparator |
protected boolean |
filterIfMissing |
protected boolean |
foundColumn |
protected boolean |
latestVersionOnly |
protected boolean |
matchedColumn |
protected CompareOperator |
op |
Modifier | Constructor and Description |
---|---|
|
SingleColumnValueFilter(byte[] family,
byte[] qualifier,
CompareOperator op,
byte[] value)
Constructor for binary compare of the value of a single column.
|
|
SingleColumnValueFilter(byte[] family,
byte[] qualifier,
CompareOperator op,
ByteArrayComparable comparator)
Constructor for binary compare of the value of a single column.
|
protected |
SingleColumnValueFilter(byte[] family,
byte[] qualifier,
CompareOperator op,
ByteArrayComparable comparator,
boolean filterIfMissing,
boolean latestVersionOnly)
Constructor for protobuf deserialization only.
|
Modifier and Type | Method and Description |
---|---|
static Filter |
createFilterFromArguments(ArrayList<byte[]> filterArguments) |
boolean |
equals(Object obj) |
Filter.ReturnCode |
filterCell(Cell c)
A way to filter based on the column family, column qualifier and/or the column value.
|
boolean |
filterRow()
Filters that never filter by rows based on previously gathered state from
Filter.filterCell(Cell) can inherit this implementation that never filters a row. |
boolean |
filterRowKey(Cell cell)
Filters a row based on the row key.
|
ByteArrayComparable |
getComparator()
Returns the comparator
|
CompareOperator |
getCompareOperator() |
byte[] |
getFamily()
Returns the family
|
boolean |
getFilterIfMissing()
Get whether entire row should be filtered if column is not found.
|
boolean |
getLatestVersionOnly()
Get whether only the latest version of the column value should be compared.
|
byte[] |
getQualifier()
Returns the qualifier
|
boolean |
hasFilterRow()
Filters that never filter by modifying the returned List of Cells can inherit this
implementation that does nothing.
|
int |
hashCode() |
boolean |
isFamilyEssential(byte[] name)
The only CF this filter needs is given column family.
|
static SingleColumnValueFilter |
parseFrom(byte[] pbBytes)
Parse a serialized representation of
SingleColumnValueFilter |
void |
reset()
Filters that are purely stateless and do nothing in their reset() methods can inherit this
null/empty implementation.
|
void |
setFilterIfMissing(boolean filterIfMissing)
Set whether entire row should be filtered if column is not found.
|
void |
setLatestVersionOnly(boolean latestVersionOnly)
Set whether only the latest version of the column value should be compared.
|
byte[] |
toByteArray()
Returns The filter serialized using pb
|
String |
toString()
Return filter's info for debugging and logging purpose.
|
filterAllRemaining, filterRowCells, getNextCellHint, transformCell
isReversed, setReversed
protected byte[] columnFamily
protected byte[] columnQualifier
protected CompareOperator op
protected ByteArrayComparable comparator
protected boolean foundColumn
protected boolean matchedColumn
protected boolean filterIfMissing
protected boolean latestVersionOnly
public SingleColumnValueFilter(byte[] family, byte[] qualifier, CompareOperator op, byte[] value)
Use the filterIfColumnMissing flag to set whether the rest of the columns in a row will be emitted if the specified column to check is not found in the row.
family
- name of column familyqualifier
- name of column qualifierop
- operatorvalue
- value to compare column values againstpublic SingleColumnValueFilter(byte[] family, byte[] qualifier, CompareOperator op, ByteArrayComparable comparator)
Use the filterIfColumnMissing flag to set whether the rest of the columns in a row will be emitted if the specified column to check is not found in the row.
family
- name of column familyqualifier
- name of column qualifierop
- operatorcomparator
- Comparator to use.protected SingleColumnValueFilter(byte[] family, byte[] qualifier, CompareOperator op, ByteArrayComparable comparator, boolean filterIfMissing, boolean latestVersionOnly)
public CompareOperator getCompareOperator()
public ByteArrayComparable getComparator()
public byte[] getFamily()
public byte[] getQualifier()
public boolean filterRowKey(Cell cell) throws IOException
Filter
Filter.filterCell(Cell)
below. If
Filter.filterAllRemaining()
returns true, then Filter.filterRowKey(Cell)
should also return
true. Concrete implementers can signal a failure condition in their code by throwing an
IOException
.filterRowKey
in class org.apache.hadoop.hbase.filter.FilterBase
cell
- The first cell coming in the new rowIOException
- in case an I/O or an filter specific failure needs to be signaled.public Filter.ReturnCode filterCell(Cell c)
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. Concrete implementers can signal a failure condition in their code by
throwing an IOException
.filterCell
in class Filter
c
- the Cell in questionFilter.ReturnCode
public boolean filterRow()
org.apache.hadoop.hbase.filter.FilterBase
Filter.filterCell(Cell)
can inherit this implementation that never filters a row.
Last chance to veto row based on previous Filter.filterCell(Cell)
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). Concrete implementers can signal a failure condition
in their code by throwing an IOException
.filterRow
in class org.apache.hadoop.hbase.filter.FilterBase
public boolean hasFilterRow()
org.apache.hadoop.hbase.filter.FilterBase
hasFilterRow
in class org.apache.hadoop.hbase.filter.FilterBase
public void reset()
org.apache.hadoop.hbase.filter.FilterBase
IOException
.reset
in class org.apache.hadoop.hbase.filter.FilterBase
public boolean getFilterIfMissing()
public void setFilterIfMissing(boolean filterIfMissing)
If true, the entire row will be skipped if the column is not found.
If false, the row will pass if the column is not found. This is default.
filterIfMissing
- flagpublic boolean getLatestVersionOnly()
public void setLatestVersionOnly(boolean latestVersionOnly)
latestVersionOnly
- flagpublic static Filter createFilterFromArguments(ArrayList<byte[]> filterArguments)
public byte[] toByteArray()
toByteArray
in class org.apache.hadoop.hbase.filter.FilterBase
public static SingleColumnValueFilter parseFrom(byte[] pbBytes) throws org.apache.hadoop.hbase.exceptions.DeserializationException
SingleColumnValueFilter
pbBytes
- A pb serialized SingleColumnValueFilter
instanceSingleColumnValueFilter
made from bytes
org.apache.hadoop.hbase.exceptions.DeserializationException
- if an error occurredtoByteArray()
public boolean isFamilyEssential(byte[] name)
isFamilyEssential
in class org.apache.hadoop.hbase.filter.FilterBase
public String toString()
org.apache.hadoop.hbase.filter.FilterBase
toString
in class org.apache.hadoop.hbase.filter.FilterBase
Copyright © 2007–2020 The Apache Software Foundation. All rights reserved.