Package org.apache.hadoop.hbase.filter
Class ColumnValueFilter
java.lang.Object
org.apache.hadoop.hbase.filter.Filter
org.apache.hadoop.hbase.filter.FilterBase
org.apache.hadoop.hbase.filter.ColumnValueFilter
Different from
SingleColumnValueFilter
which returns an entire row when specified
condition is matched, ColumnValueFilter
return the matched cell only.
This filter is used to filter cells based on column and value. It takes a
CompareOperator
operator (<, <=, =, !=, >, >=), and and a
ByteArrayComparable
comparator.
-
Nested Class Summary
Nested classes/interfaces inherited from class org.apache.hadoop.hbase.filter.Filter
Filter.ReturnCode
-
Field Summary
Modifier and TypeFieldDescriptionprivate boolean
private final ByteArrayComparable
private final byte[]
private final CompareOperator
private final byte[]
-
Constructor Summary
ConstructorDescriptionColumnValueFilter
(byte[] family, byte[] qualifier, CompareOperator op, byte[] value) ColumnValueFilter
(byte[] family, byte[] qualifier, CompareOperator op, ByteArrayComparable comparator) -
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.private boolean
compareValue
(CompareOperator op, ByteArrayComparable comparator, Cell cell) This method is used to determine a cell should be included or filtered out.(package private) org.apache.hadoop.hbase.shaded.protobuf.generated.FilterProtos.ColumnValueFilter
convert()
Returns A pb instance to represent this instance.static Filter
createFilterFromArguments
(ArrayList<byte[]> filterArguments) Creating this filter by reflection, it is used byParseFilter
,boolean
filterCell
(Cell c) A way to filter based on the column family, column qualifier and/or the column value.boolean
filterRowKey
(Cell cell) Filters a row based on the row key.Returns the comparatorReturns operatorbyte[]
Returns the column familybyte[]
Returns the qualifierint
hashCode()
boolean
isFamilyEssential
(byte[] name) By default, we require all scan's column families to be present.static ColumnValueFilter
parseFrom
(byte[] pbBytes) Parse a serialized representation ofColumnValueFilter
void
reset()
Filters that are purely stateless and do nothing in their reset() methods can inherit this null/empty implementation.byte[]
Return length 0 byte array for Filters that don't require special serializationtoString()
Return filter's info for debugging and logging purpose.Methods inherited from class org.apache.hadoop.hbase.filter.FilterBase
filterAllRemaining, filterRow, filterRowCells, getNextCellHint, hasFilterRow, transformCell
Methods inherited from class org.apache.hadoop.hbase.filter.Filter
isReversed, setReversed
-
Field Details
-
family
-
qualifier
-
op
-
comparator
-
columnFound
-
-
Constructor Details
-
ColumnValueFilter
-
ColumnValueFilter
public ColumnValueFilter(byte[] family, byte[] qualifier, CompareOperator op, ByteArrayComparable comparator)
-
-
Method Details
-
getCompareOperator
Returns operator -
getComparator
Returns the comparator -
getFamily
Returns the column family -
getQualifier
Returns the qualifier -
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
- Throws:
IOException
- in case an I/O or an filter specific failure needs to be signaled.
-
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
- Throws:
IOException
- in case an I/O or an filter specific failure needs to be signaled.- See Also:
-
compareValue
This method is used to determine a cell should be included or filtered out.- Parameters:
op
- one of operatorsCompareOperator
comparator
- comparator used to compare cells.cell
- cell to be compared.- Returns:
- true means cell should be filtered out, included otherwise.
-
createFilterFromArguments
Creating this filter by reflection, it is used byParseFilter
,- Parameters:
filterArguments
- arguments for creating a ColumnValueFilter- Returns:
- a ColumnValueFilter
-
convert
org.apache.hadoop.hbase.shaded.protobuf.generated.FilterProtos.ColumnValueFilter convert()Returns A pb instance to represent this instance. -
parseFrom
Parse a serialized representation ofColumnValueFilter
- Parameters:
pbBytes
- A pb serializedColumnValueFilter
instance- Returns:
- An instance of
ColumnValueFilter
made frombytes
- Throws:
DeserializationException
- if an error occurred- See Also:
-
toByteArray
Description copied from class:FilterBase
Return length 0 byte array for Filters that don't require special serialization- Overrides:
toByteArray
in classFilterBase
- Returns:
- The filter serialized using pb
- Throws:
IOException
- in case an I/O or an filter specific failure needs to be signaled.
-
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
Description copied from class:FilterBase
By default, we require all scan's column families to be present. Our subclasses may be more precise. Check that given column family is essential for filter to check row. Most filters always return true here. But some could have more sophisticated logic which could significantly reduce scanning process by not even touching columns until we are 100% sure that it's data is needed in result. Concrete implementers can signal a failure condition in their code by throwing anIOException
.- Overrides:
isFamilyEssential
in classFilterBase
- Throws:
IOException
- in case an I/O or an filter specific failure needs to be signaled.
-
toString
Description copied from class:FilterBase
Return filter's info for debugging and logging purpose.- Overrides:
toString
in classFilterBase
-
equals
-
hashCode
-