@InterfaceAudience.Public public class SingleColumnValueFilter extends FilterBase
CompareFilter.CompareOp
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,
CompareFilter.CompareOp compareOp,
byte[] value)
Deprecated.
Since 2.0.0. Will be removed in 3.0.0. Use
SingleColumnValueFilter(byte[], byte[], CompareOperator, byte[]) instead. |
|
SingleColumnValueFilter(byte[] family,
byte[] qualifier,
CompareFilter.CompareOp compareOp,
ByteArrayComparable comparator)
Deprecated.
Since 2.0.0. Will be removed in 3.0.0. Use
SingleColumnValueFilter(byte[], byte[], CompareOperator, ByteArrayComparable) instead. |
protected |
SingleColumnValueFilter(byte[] family,
byte[] qualifier,
CompareFilter.CompareOp compareOp,
ByteArrayComparable comparator,
boolean filterIfMissing,
boolean latestVersionOnly)
Deprecated.
Since 2.0.0. Will be removed in 3.0.0. Use
SingleColumnValueFilter(byte[], byte[], CompareOperator, ByteArrayComparable,
boolean, boolean) instead. |
|
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 |
---|---|
(package private) boolean |
areSerializedFieldsEqual(Filter o)
Default implementation so that writers of custom filters aren't forced to implement.
|
(package private) org.apache.hadoop.hbase.shaded.protobuf.generated.FilterProtos.SingleColumnValueFilter |
convert() |
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.
|
private boolean |
filterColumnValue(Cell cell) |
Filter.ReturnCode |
filterKeyValue(Cell c)
Deprecated.
|
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() |
CompareOperator |
getCompareOperator() |
byte[] |
getFamily() |
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.
|
CompareFilter.CompareOp |
getOperator()
Deprecated.
since 2.0.0. Will be removed in 3.0.0. Use
getCompareOperator() instead. |
byte[] |
getQualifier() |
boolean |
hasFilterRow()
Fitlers 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) |
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()
Return length 0 byte array for Filters that don't require special serialization
|
String |
toString()
Return filter's info for debugging and logging purpose.
|
filterAllRemaining, filterRowCells, filterRowKey, 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
@Deprecated public SingleColumnValueFilter(byte[] family, byte[] qualifier, CompareFilter.CompareOp compareOp, byte[] value)
SingleColumnValueFilter(byte[], byte[], CompareOperator, byte[])
instead.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 qualifiercompareOp
- operatorvalue
- value to compare column values againstpublic 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 against@Deprecated public SingleColumnValueFilter(byte[] family, byte[] qualifier, CompareFilter.CompareOp compareOp, ByteArrayComparable comparator)
SingleColumnValueFilter(byte[], byte[], CompareOperator, ByteArrayComparable)
instead.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 qualifiercompareOp
- operatorcomparator
- Comparator to use.public 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.@Deprecated protected SingleColumnValueFilter(byte[] family, byte[] qualifier, CompareFilter.CompareOp compareOp, ByteArrayComparable comparator, boolean filterIfMissing, boolean latestVersionOnly)
SingleColumnValueFilter(byte[], byte[], CompareOperator, ByteArrayComparable,
boolean, boolean)
instead.family
- qualifier
- compareOp
- comparator
- filterIfMissing
- latestVersionOnly
- protected SingleColumnValueFilter(byte[] family, byte[] qualifier, CompareOperator op, ByteArrayComparable comparator, boolean filterIfMissing, boolean latestVersionOnly)
family
- qualifier
- op
- comparator
- filterIfMissing
- latestVersionOnly
- @Deprecated public CompareFilter.CompareOp getOperator()
getCompareOperator()
instead.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 FilterBase
cell
- The first cell coming in the new rowIOException
- in case an I/O or an filter specific failure needs to be signaled.@Deprecated public Filter.ReturnCode filterKeyValue(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
.filterKeyValue
in class Filter
c
- the Cell in questionFilter.ReturnCode
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
private boolean filterColumnValue(Cell cell)
public boolean filterRow()
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 FilterBase
public boolean hasFilterRow()
FilterBase
hasFilterRow
in class FilterBase
public void reset()
FilterBase
IOException
.reset
in class 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)
org.apache.hadoop.hbase.shaded.protobuf.generated.FilterProtos.SingleColumnValueFilter convert()
public byte[] toByteArray()
FilterBase
toByteArray
in class FilterBase
public static SingleColumnValueFilter parseFrom(byte[] pbBytes) throws DeserializationException
pbBytes
- A pb serialized SingleColumnValueFilter
instanceSingleColumnValueFilter
made from bytes
DeserializationException
toByteArray()
boolean areSerializedFieldsEqual(Filter o)
FilterBase
areSerializedFieldsEqual
in class FilterBase
public boolean isFamilyEssential(byte[] name)
isFamilyEssential
in class FilterBase
public String toString()
FilterBase
toString
in class FilterBase
Copyright © 2007–2020 The Apache Software Foundation. All rights reserved.