|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.hadoop.hbase.filter.FilterBase
org.apache.hadoop.hbase.filter.SingleColumnValueFilter
public class SingleColumnValueFilter
This filter is used to filter cells based on value. It takes a 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
.
Nested Class Summary |
---|
Nested classes/interfaces inherited from interface org.apache.hadoop.hbase.filter.Filter |
---|
Filter.ReturnCode |
Field Summary | |
---|---|
protected byte[] |
columnFamily
|
protected byte[] |
columnQualifier
|
Constructor Summary | |
---|---|
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. |
Method Summary | |
---|---|
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()
|
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. |
void |
write(DataOutput out)
|
Methods inherited from class org.apache.hadoop.hbase.filter.FilterBase |
---|
filterAllRemaining, filterRow, filterRowKey, getNextKeyHint, hasFilterRow |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected byte[] columnFamily
protected byte[] columnQualifier
Constructor Detail |
---|
public SingleColumnValueFilter()
public SingleColumnValueFilter(byte[] family, byte[] qualifier, CompareFilter.CompareOp compareOp, byte[] value)
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.Method Detail |
---|
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 question
Filter.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 void readFields(DataInput in) throws IOException
IOException
public void write(DataOutput out) throws IOException
IOException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |