Class SingleColumnValueFilter
- Direct Known Subclasses:
SingleColumnValueExcludeFilter
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
.
-
Nested Class Summary
Nested classes/interfaces inherited from class org.apache.hadoop.hbase.filter.Filter
Filter.ReturnCode
-
Field Summary
Modifier and TypeFieldDescriptionprotected byte[]
protected byte[]
protected ByteArrayComparable
protected boolean
protected boolean
protected boolean
protected boolean
protected CompareOperator
-
Constructor Summary
ModifierConstructorDescriptionSingleColumnValueFilter
(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. -
Method Summary
Modifier and TypeMethodDescription(package private) boolean
Returns true if and only if the fields of the filter that are serialized are equal to the corresponding fields in other.(package private) org.apache.hadoop.hbase.shaded.protobuf.generated.FilterProtos.SingleColumnValueFilter
convert()
static Filter
createFilterFromArguments
(ArrayList<byte[]> filterArguments) boolean
filterCell
(Cell c) A way to filter based on the column family, column qualifier and/or the column value.private boolean
filterColumnValue
(Cell cell) boolean
Filters that never filter by rows based on previously gathered state fromFilter.filterCell(Cell)
can inherit this implementation that never filters a row.boolean
filterRowKey
(Cell cell) Filters a row based on the row key.Returns the comparatorbyte[]
Returns the familyboolean
Get whether entire row should be filtered if column is not found.boolean
Get whether only the latest version of the column value should be compared.byte[]
Returns the qualifierboolean
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 ofSingleColumnValueFilter
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[]
Returns The filter serialized using pbtoString()
Return filter's info for debugging and logging purpose.Methods inherited from class org.apache.hadoop.hbase.filter.FilterBase
filterAllRemaining, filterRowCells, getNextCellHint, transformCell
Methods inherited from class org.apache.hadoop.hbase.filter.Filter
isReversed, setReversed
-
Field Details
-
columnFamily
-
columnQualifier
-
op
-
comparator
-
foundColumn
-
matchedColumn
-
filterIfMissing
-
latestVersionOnly
-
-
Constructor Details
-
SingleColumnValueFilter
Constructor for binary compare of the value of a single column. If the column is found and the condition passes, all columns of the row will be emitted. If the condition fails, the row will not be emitted.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.
- Parameters:
family
- name of column familyqualifier
- name of column qualifierop
- operatorvalue
- value to compare column values against
-
SingleColumnValueFilter
public SingleColumnValueFilter(byte[] family, byte[] qualifier, CompareOperator op, ByteArrayComparable comparator) Constructor for binary compare of the value of a single column. If the column is found and the condition passes, all columns of the row will be emitted. If the condition fails, the row will not be emitted.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.
- Parameters:
family
- name of column familyqualifier
- name of column qualifierop
- operatorcomparator
- Comparator to use.
-
SingleColumnValueFilter
protected SingleColumnValueFilter(byte[] family, byte[] qualifier, CompareOperator op, ByteArrayComparable comparator, boolean filterIfMissing, boolean latestVersionOnly) Constructor for protobuf deserialization only.
-
-
Method Details
-
getCompareOperator
-
getComparator
Returns the comparator -
getFamily
Returns the family -
getQualifier
Returns the qualifier -
filterRowKey
Description copied from class:Filter
Filters a row based on the row key. If this returns true, the entire row will be excluded. If false, each KeyValue in the row will be passed toFilter.filterCell(Cell)
below. IfFilter.filterAllRemaining()
returns true, thenFilter.filterRowKey(Cell)
should also return true. Concrete implementers can signal a failure condition in their code by throwing anIOException
.- Overrides:
filterRowKey
in classFilterBase
- Parameters:
cell
- The first cell coming in the new row- Returns:
- true, remove entire row, false, include the row (maybe).
- Throws:
IOException
- in case an I/O or an filter specific failure needs to be signaled.
-
filterCell
Description copied from class:Filter
A way to filter based on the column family, column qualifier and/or the column value. Return code is described below. This allows filters to filter only certain number of columns, then terminate without matching ever column. If filterRowKey returns true, filterCell needs to be consistent with it. filterCell can assume that filterRowKey has already been called for the row. If your filter returnsReturnCode.NEXT_ROW
, it should returnReturnCode.NEXT_ROW
untilFilter.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 anIOException
.- Overrides:
filterCell
in classFilter
- Parameters:
c
- the Cell in question- Returns:
- code as described below
- See Also:
-
filterColumnValue
-
filterRow
Description copied from class:FilterBase
Filters that never filter by rows based on previously gathered state fromFilter.filterCell(Cell)
can inherit this implementation that never filters a row. Last chance to veto row based on previousFilter.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 anIOException
.- Overrides:
filterRow
in classFilterBase
- Returns:
- true to exclude row, false to include row.
-
hasFilterRow
Description copied from class:FilterBase
Filters that never filter by modifying the returned List of Cells can inherit this implementation that does nothing. Primarily used to check for conflicts with scans(such as scans that do not read a full row at a time).- Overrides:
hasFilterRow
in classFilterBase
- Returns:
- True if this filter actively uses filterRowCells(List) or filterRow().
-
reset
Description copied from class:FilterBase
Filters that are purely stateless and do nothing in their reset() methods can inherit this null/empty implementation. Reset the state of the filter between rows. Concrete implementers can signal a failure condition in their code by throwing anIOException
.- Overrides:
reset
in classFilterBase
-
getFilterIfMissing
Get whether entire row should be filtered if column is not found.- Returns:
- true if row should be skipped if column not found, false if row should be let through anyways
-
setFilterIfMissing
Set whether entire row should be filtered if column is not found.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.
- Parameters:
filterIfMissing
- flag
-
getLatestVersionOnly
Get whether only the latest version of the column value should be compared. If true, the row will be returned if only the latest version of the column value matches. If false, the row will be returned if any version of the column value matches. The default is true.- Returns:
- return value
-
setLatestVersionOnly
Set whether only the latest version of the column value should be compared. If true, the row will be returned if only the latest version of the column value matches. If false, the row will be returned if any version of the column value matches. The default is true.- Parameters:
latestVersionOnly
- flag
-
createFilterFromArguments
-
convert
org.apache.hadoop.hbase.shaded.protobuf.generated.FilterProtos.SingleColumnValueFilter convert() -
toByteArray
Returns The filter serialized using pb- Overrides:
toByteArray
in classFilterBase
- Returns:
- The filter serialized using pb
-
parseFrom
Parse a serialized representation ofSingleColumnValueFilter
- Parameters:
pbBytes
- A pb serializedSingleColumnValueFilter
instance- Returns:
- An instance of
SingleColumnValueFilter
made frombytes
- Throws:
DeserializationException
- if an error occurred- See Also:
-
areSerializedFieldsEqual
Returns true if and only if the fields of the filter that are serialized are equal to the corresponding fields in other. Used for testing.- Overrides:
areSerializedFieldsEqual
in classFilterBase
- Returns:
- true if and only if the fields of the filter that are serialized are equal to the corresponding fields in other. Used for testing.
-
isFamilyEssential
The only CF this filter needs is given column family. So, it's the only essential column in whole scan. If filterIfMissing == false, all families are essential, because of possibility of skipping the rows without any data in filtered CF.- Overrides:
isFamilyEssential
in classFilterBase
-
toString
Description copied from class:FilterBase
Return filter's info for debugging and logging purpose.- Overrides:
toString
in classFilterBase
-
equals
-
hashCode
-