@InterfaceAudience.Public @InterfaceStability.Stable public class SkipFilter extends FilterBase
For example, if all columns in a row represent weights of different things,
with the values being the actual weights, and we want to filter out the
entire row if any of its weights are zero. In this case, we want to prevent
rows from being emitted if a single key is filtered. Combine this filter
with a ValueFilter
:
scan.setFilter(new SkipFilter(new ValueFilter(CompareOp.NOT_EQUAL, new BinaryComparator(Bytes.toBytes(0)))); Any row which contained a column whose value was 0 will be filtered out (since ValueFilter will not pass that Cell). Without this filter, the other non-zero valued columns in the row would still be emitted.
Filter.ReturnCode
Constructor and Description |
---|
SkipFilter(Filter filter) |
Modifier and Type | Method and Description |
---|---|
Filter.ReturnCode |
filterKeyValue(Cell v)
A way to filter based on the column family, column qualifier and/or the column value.
|
boolean |
filterRow()
Filters that never filter by rows based on previously gathered state from
Filter.filterKeyValue(Cell) can inherit this implementation that
never filters a row. |
Filter |
getFilter() |
boolean |
hasFilterRow()
Fitlers that never filter by modifying the returned List of Cells can
inherit this implementation that does nothing.
|
boolean |
isFamilyEssential(byte[] name)
By default, we require all scan's column families to be present.
|
static SkipFilter |
parseFrom(byte[] pbBytes) |
void |
reset()
Filters that are purely stateless and do nothing in their reset() methods can inherit
this null/empty implementation.
|
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.
|
Cell |
transformCell(Cell v)
By default no transformation takes place
|
createFilterFromArguments, filterAllRemaining, filterRowCells, filterRowKey, getNextCellHint, getNextKeyHint, transform
isReversed, setReversed
public SkipFilter(Filter filter)
public Filter getFilter()
public void reset() throws IOException
FilterBase
reset
in class FilterBase
IOException
- in case an I/O or an filter specific failure needs to be signaled.public Filter.ReturnCode filterKeyValue(Cell v) throws IOException
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
v
- the Cell in questionIOException
- in case an I/O or an filter specific failure needs to be signaled.Filter.ReturnCode
public Cell transformCell(Cell v) throws IOException
FilterBase
transformCell
in class FilterBase
v
- the KeyValue in questionIOException
- in case an I/O or an filter specific failure needs to be signaled.The transformed KeyValue is what is eventually returned to the client. Most filters will
return the passed KeyValue unchanged.
,
for an example of a
transformation.
Concrete implementers can signal a failure condition in their code by throwing an
{@link IOException}.
public boolean filterRow()
FilterBase
Filter.filterKeyValue(Cell)
can inherit this implementation that
never filters a row.filterRow
in class FilterBase
public boolean hasFilterRow()
FilterBase
hasFilterRow
in class FilterBase
public byte[] toByteArray() throws IOException
FilterBase
toByteArray
in class FilterBase
IOException
- in case an I/O or an filter specific failure needs to be signaled.public static SkipFilter parseFrom(byte[] pbBytes) throws DeserializationException
pbBytes
- A pb serialized SkipFilter
instanceSkipFilter
made from bytes
DeserializationException
toByteArray()
public boolean isFamilyEssential(byte[] name) throws IOException
FilterBase
isFamilyEssential
in class FilterBase
IOException
- in case an I/O or an filter specific failure needs to be signaled.public String toString()
FilterBase
toString
in class FilterBase