org.apache.hadoop.hbase.filter
Class SkipFilter

java.lang.Object
  extended by org.apache.hadoop.hbase.filter.Filter
      extended by org.apache.hadoop.hbase.filter.FilterBase
          extended by org.apache.hadoop.hbase.filter.SkipFilter

@InterfaceAudience.Public
@InterfaceStability.Stable
public class SkipFilter
extends org.apache.hadoop.hbase.filter.FilterBase

A wrapper filter that filters an entire row if any of the Cell checks do not pass.

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.


Nested Class Summary
 
Nested classes/interfaces inherited from class org.apache.hadoop.hbase.filter.Filter
Filter.ReturnCode
 
Field Summary
 
Fields inherited from class org.apache.hadoop.hbase.filter.Filter
reversed
 
Constructor Summary
SkipFilter(Filter filter)
           
 
Method Summary
 Filter.ReturnCode filterKeyValue(Cell v)
          Filters that dont filter by key value can inherit this implementation that includes all Cells.
 boolean filterRow()
          Filters that never filter by rows based on previously gathered state from FilterBase.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
 
Methods inherited from class org.apache.hadoop.hbase.filter.FilterBase
createFilterFromArguments, filterAllRemaining, filterRow, filterRowCells, filterRowKey, getNextCellHint, getNextKeyHint, transform
 
Methods inherited from class org.apache.hadoop.hbase.filter.Filter
isReversed, setReversed
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SkipFilter

public SkipFilter(Filter filter)
Method Detail

getFilter

public Filter getFilter()

reset

public void reset()
           throws IOException
Description copied from class: org.apache.hadoop.hbase.filter.FilterBase
Filters that are purely stateless and do nothing in their reset() methods can inherit this null/empty implementation.

Overrides:
reset in class org.apache.hadoop.hbase.filter.FilterBase
Throws:
IOException - in case an I/O or an filter specific failure needs to be signaled.

filterKeyValue

public Filter.ReturnCode filterKeyValue(Cell v)
                                 throws IOException
Description copied from class: org.apache.hadoop.hbase.filter.FilterBase
Filters that dont filter by key value can inherit this implementation that includes all Cells.

Overrides:
filterKeyValue in class org.apache.hadoop.hbase.filter.FilterBase
Parameters:
v - 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:
Filter.ReturnCode

transformCell

public Cell transformCell(Cell v)
                   throws IOException
Description copied from class: org.apache.hadoop.hbase.filter.FilterBase
By default no transformation takes place

Overrides:
transformCell in class org.apache.hadoop.hbase.filter.FilterBase
Parameters:
v - the KeyValue in question
Returns:
the changed KeyValue
Throws:
IOException - in case an I/O or an filter specific failure needs to be signaled.
See Also:
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}.

filterRow

public boolean filterRow()
Description copied from class: org.apache.hadoop.hbase.filter.FilterBase
Filters that never filter by rows based on previously gathered state from FilterBase.filterKeyValue(Cell) can inherit this implementation that never filters a row.

Overrides:
filterRow in class org.apache.hadoop.hbase.filter.FilterBase
Returns:
true to exclude row, false to include row.

hasFilterRow

public boolean hasFilterRow()
Description copied from class: org.apache.hadoop.hbase.filter.FilterBase
Fitlers that never filter by modifying the returned List of Cells can inherit this implementation that does nothing.

Overrides:
hasFilterRow in class org.apache.hadoop.hbase.filter.FilterBase
Returns:
True if this filter actively uses filterRow(List) or filterRow().

toByteArray

public byte[] toByteArray()
                   throws IOException
Description copied from class: org.apache.hadoop.hbase.filter.FilterBase
Return length 0 byte array for Filters that don't require special serialization

Overrides:
toByteArray in class org.apache.hadoop.hbase.filter.FilterBase
Returns:
The filter serialized using pb
Throws:
IOException - in case an I/O or an filter specific failure needs to be signaled.

parseFrom

public static SkipFilter parseFrom(byte[] pbBytes)
                            throws org.apache.hadoop.hbase.exceptions.DeserializationException
Parameters:
pbBytes - A pb serialized SkipFilter instance
Returns:
An instance of SkipFilter made from bytes
Throws:
org.apache.hadoop.hbase.exceptions.DeserializationException
See Also:
toByteArray()

isFamilyEssential

public boolean isFamilyEssential(byte[] name)
                          throws IOException
Description copied from class: org.apache.hadoop.hbase.filter.FilterBase
By default, we require all scan's column families to be present. Our subclasses may be more precise.

Overrides:
isFamilyEssential in class org.apache.hadoop.hbase.filter.FilterBase
Throws:
IOException - in case an I/O or an filter specific failure needs to be signaled.

toString

public String toString()
Description copied from class: org.apache.hadoop.hbase.filter.FilterBase
Return filter's info for debugging and logging purpose.

Overrides:
toString in class org.apache.hadoop.hbase.filter.FilterBase


Copyright © 2015 The Apache Software Foundation. All rights reserved.