public class SingleColumnValueFilter extends FilterBase
CompareFilter.CompareOp
operator (equal, greater, not equal, etc), and either a byte [] value or
a WritableByteArrayComparable.
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 Scan
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 |
Constructor and Description |
---|
SingleColumnValueFilter()
Writable constructor, do not use.
|
SingleColumnValueFilter(byte[] family,
byte[] qualifier,
CompareFilter.CompareOp compareOp,
byte[] value)
Constructor for binary compare of the value of a single column.
|
SingleColumnValueFilter(byte[] family,
byte[] qualifier,
CompareFilter.CompareOp compareOp,
WritableByteArrayComparable comparator)
Constructor for binary compare of the value of a single column.
|
Modifier and Type | Method and Description |
---|---|
static Filter |
createFilterFromArguments(ArrayList<byte[]> filterArguments) |
Filter.ReturnCode |
filterKeyValue(KeyValue keyValue)
Filters that dont filter by key value can inherit this implementation that
includes all KeyValues.
|
boolean |
filterRow()
Filters that never filter by rows based on previously gathered state from
FilterBase.filterKeyValue(KeyValue) can inherit this implementation that
never filters a row. |
WritableByteArrayComparable |
getComparator() |
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() |
byte[] |
getQualifier() |
boolean |
isFamilyEssential(byte[] name)
The only CF this filter needs is given column family.
|
void |
readFields(DataInput in) |
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.
|
String |
toString()
Return filter's info for debugging and logging purpose.
|
void |
write(DataOutput out) |
filterAllRemaining, filterRow, filterRowKey, getNextKeyHint, hasFilterRow, isFamilyEssential, transform
protected byte[] columnFamily
protected byte[] columnQualifier
public SingleColumnValueFilter()
public SingleColumnValueFilter(byte[] family, byte[] qualifier, CompareFilter.CompareOp compareOp, 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 qualifiercompareOp
- operatorvalue
- value to compare column values againstpublic SingleColumnValueFilter(byte[] family, byte[] qualifier, CompareFilter.CompareOp compareOp, WritableByteArrayComparable 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 qualifiercompareOp
- operatorcomparator
- Comparator to use.public CompareFilter.CompareOp getOperator()
public WritableByteArrayComparable getComparator()
public byte[] getFamily()
public byte[] getQualifier()
public Filter.ReturnCode filterKeyValue(KeyValue keyValue)
FilterBase
filterKeyValue
in interface Filter
filterKeyValue
in class FilterBase
keyValue
- the KeyValue in questionFilter.ReturnCode
public boolean filterRow()
FilterBase
FilterBase.filterKeyValue(KeyValue)
can inherit this implementation that
never filters a row.filterRow
in interface Filter
filterRow
in class FilterBase
public void reset()
FilterBase
reset
in interface Filter
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)
public void readFields(DataInput in) throws IOException
IOException
public void write(DataOutput out) throws IOException
IOException
public boolean isFamilyEssential(byte[] name)
isFamilyEssential
in class FilterBase
public String toString()
FilterBase
toString
in class FilterBase
Copyright © 2014 The Apache Software Foundation. All Rights Reserved.