org.apache.hadoop.hbase.filter
Class FilterBase

java.lang.Object
  extended by org.apache.hadoop.hbase.filter.Filter
      extended by org.apache.hadoop.hbase.filter.FilterBase
Direct Known Subclasses:
ColumnCountGetFilter, ColumnPaginationFilter, ColumnPrefixFilter, ColumnRangeFilter, CompareFilter, FirstKeyOnlyFilter, FuzzyRowFilter, InclusiveStopFilter, KeyOnlyFilter, MultipleColumnPrefixFilter, PageFilter, PrefixFilter, RandomRowFilter, SingleColumnValueFilter, SkipFilter, TimestampsFilter, WhileMatchFilter

@InterfaceAudience.Private
public abstract class FilterBase
extends Filter

Abstract base class to help you implement new Filters. Common "ignore" or NOOP type methods can go here, helping to reduce boiler plate in an ever-expanding filter library. If you could instantiate FilterBase, it would end up being a "null" filter - that is one that never filters anything.


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
FilterBase()
           
 
Method Summary
static Filter createFilterFromArguments(ArrayList<byte[]> filterArguments)
          Given the filter's arguments it constructs the filter
 boolean filterAllRemaining()
          Filters that never filter all remaining can inherit this implementation that never stops the filter early.
 Filter.ReturnCode filterKeyValue(Cell ignored)
          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 filterKeyValue(Cell) can inherit this implementation that never filters a row.
 void filterRow(List<KeyValue> kvs)
          Deprecated. 
 void filterRowCells(List<Cell> ignored)
          Filters that never filter by modifying the returned List of Cells can inherit this implementation that does nothing.
 boolean filterRowKey(byte[] buffer, int offset, int length)
          Filters that do not filter by row key can inherit this implementation that never filters anything.
 Cell getNextCellHint(Cell currentKV)
          Filters that are not sure which key must be next seeked to, can inherit this implementation that, by default, returns a null Cell.
 KeyValue getNextKeyHint(KeyValue currentKV)
          Deprecated. 
 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.
 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.
 KeyValue transform(KeyValue currentKV)
          Deprecated. 
 Cell transformCell(Cell v)
          By default no transformation takes place
 
Methods inherited from class org.apache.hadoop.hbase.filter.Filter
isReversed, parseFrom, setReversed
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

FilterBase

public FilterBase()
Method Detail

reset

public void reset()
           throws IOException
Filters that are purely stateless and do nothing in their reset() methods can inherit this null/empty implementation.

Specified by:
reset in class Filter
Throws:
IOException - in case an I/O or an filter specific failure needs to be signaled.

filterRowKey

public boolean filterRowKey(byte[] buffer,
                            int offset,
                            int length)
                     throws IOException
Filters that do not filter by row key can inherit this implementation that never filters anything. (ie: returns false).

Specified by:
filterRowKey in class Filter
Parameters:
buffer - buffer containing row key
offset - offset into buffer where row key starts
length - length of the row key
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.

filterAllRemaining

public boolean filterAllRemaining()
                           throws IOException
Filters that never filter all remaining can inherit this implementation that never stops the filter early.

Specified by:
filterAllRemaining in class Filter
Returns:
true to end scan, false to continue.
Throws:
IOException - in case an I/O or an filter specific failure needs to be signaled.

filterKeyValue

public Filter.ReturnCode filterKeyValue(Cell ignored)
                                 throws IOException
Filters that dont filter by key value can inherit this implementation that includes all Cells.

Specified by:
filterKeyValue in class Filter
Parameters:
ignored - 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
By default no transformation takes place

Specified by:
transformCell in class Filter
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}.

transform

@Deprecated
public KeyValue transform(KeyValue currentKV)
                   throws IOException
Deprecated. 

WARNING: please to not override this method. Instead override transformCell(Cell). This is for transition from 0.94 -> 0.96

Specified by:
transform in class Filter
Throws:
IOException

filterRowCells

public void filterRowCells(List<Cell> ignored)
                    throws IOException
Filters that never filter by modifying the returned List of Cells can inherit this implementation that does nothing.

Specified by:
filterRowCells in class Filter
Parameters:
ignored - the list of Cells to be filtered
Throws:
IOException - in case an I/O or an filter specific failure needs to be signaled.

filterRow

@Deprecated
public void filterRow(List<KeyValue> kvs)
               throws IOException
Deprecated. 

WARNING: please to not override this method. Instead override transformCell(Cell). This is for transition from 0.94 -> 0.96

Specified by:
filterRow in class Filter
Throws:
IOException

hasFilterRow

public boolean hasFilterRow()
Fitlers that never filter by modifying the returned List of Cells can inherit this implementation that does nothing.

Specified by:
hasFilterRow in class Filter
Returns:
True if this filter actively uses filterRow(List) or filterRow().

filterRow

public boolean filterRow()
                  throws IOException
Filters that never filter by rows based on previously gathered state from filterKeyValue(Cell) can inherit this implementation that never filters a row.

Specified by:
filterRow in class Filter
Returns:
true to exclude row, false to include row.
Throws:
IOException - in case an I/O or an filter specific failure needs to be signaled.

getNextKeyHint

@Deprecated
public KeyValue getNextKeyHint(KeyValue currentKV)
                        throws IOException
Deprecated. 

This method is deprecated and you should override Cell getNextKeyHint(Cell) instead.

Specified by:
getNextKeyHint in class Filter
Throws:
IOException

getNextCellHint

public Cell getNextCellHint(Cell currentKV)
                     throws IOException
Filters that are not sure which key must be next seeked to, can inherit this implementation that, by default, returns a null Cell.

Specified by:
getNextCellHint in class Filter
Returns:
KeyValue which must be next seeked. return null if the filter is not sure which key to seek to next.
Throws:
IOException - in case an I/O or an filter specific failure needs to be signaled.

isFamilyEssential

public boolean isFamilyEssential(byte[] name)
                          throws IOException
By default, we require all scan's column families to be present. Our subclasses may be more precise.

Specified by:
isFamilyEssential in class Filter
Throws:
IOException - in case an I/O or an filter specific failure needs to be signaled.

createFilterFromArguments

public static Filter createFilterFromArguments(ArrayList<byte[]> filterArguments)
Given the filter's arguments it constructs the filter

Parameters:
filterArguments - the filter's arguments
Returns:
constructed filter object

toString

public String toString()
Return filter's info for debugging and logging purpose.

Overrides:
toString in class Object

toByteArray

public byte[] toByteArray()
                   throws IOException
Return length 0 byte array for Filters that don't require special serialization

Specified by:
toByteArray in class Filter
Returns:
The filter serialized using pb
Throws:
IOException - in case an I/O or an filter specific failure needs to be signaled.


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