org.apache.hadoop.hbase.filter
Class FilterBase

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

public abstract class FilterBase
extends Object
implements 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 interface org.apache.hadoop.hbase.filter.Filter
Filter.ReturnCode
 
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(KeyValue ignored)
          Filters that dont filter by key value can inherit this implementation that includes all KeyValues.
 boolean filterRow()
          Filters that never filter by rows based on previously gathered state from filterKeyValue(KeyValue) can inherit this implementation that never filters a row.
 void filterRow(List<KeyValue> ignored)
          Filters that never filter by modifying the returned List of KeyValues 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.
 KeyValue getNextKeyHint(KeyValue currentKV)
          Filters that are not sure which key must be next seeked to, can inherit this implementation that, by default, returns a null KeyValue.
 boolean hasFilterRow()
          Fitlers that never filter by modifying the returned List of KeyValues can inherit this implementation that does nothing.
 boolean isFamilyEssential(byte[] name)
          Check that given column family is essential for filter to check row.
static boolean isFamilyEssential(Filter filter, byte[] name)
          Check that given column family is essential for filter to check row.
 void reset()
          Filters that are purely stateless and do nothing in their reset() methods can inherit this null/empty implementation.
 String toString()
          Return filter's info for debugging and logging purpose.
 KeyValue transform(KeyValue v)
          By default no transformation takes place
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.apache.hadoop.io.Writable
readFields, write
 

Constructor Detail

FilterBase

public FilterBase()
Method Detail

reset

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

Specified by:
reset in interface Filter

filterRowKey

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

Specified by:
filterRowKey in interface 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).

filterAllRemaining

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

Specified by:
filterAllRemaining in interface Filter
Returns:
true to end scan, false to continue.

filterKeyValue

public Filter.ReturnCode filterKeyValue(KeyValue ignored)
Filters that dont filter by key value can inherit this implementation that includes all KeyValues.

Specified by:
filterKeyValue in interface Filter
Parameters:
ignored - the KeyValue in question
Returns:
code as described below
See Also:
Filter.ReturnCode

transform

public KeyValue transform(KeyValue v)
By default no transformation takes place

Specified by:
transform in interface Filter
Parameters:
v - the KeyValue in question
Returns:
the changed KeyValue
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.

filterRow

public void filterRow(List<KeyValue> ignored)
Filters that never filter by modifying the returned List of KeyValues can inherit this implementation that does nothing.

Specified by:
filterRow in interface Filter
Parameters:
ignored - the list of keyvalues to be filtered

hasFilterRow

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

Specified by:
hasFilterRow in interface Filter
Returns:
True if this filter actively uses filterRow(List). Primarily used to check for conflicts with scans(such as scans that do not read a full row at a time)

filterRow

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

Specified by:
filterRow in interface Filter
Returns:
true to exclude row, false to include row.

getNextKeyHint

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

Specified by:
getNextKeyHint in interface Filter
Returns:
KeyValue which must be next seeked. return null if the filter is not sure which key to seek to next.

isFamilyEssential

public boolean isFamilyEssential(byte[] name)
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. By default, we require all scan's column families to be present. Our subclasses may be more precise.


isFamilyEssential

public static boolean isFamilyEssential(Filter filter,
                                        byte[] name)
Check that given column family is essential for filter to check row. This accommodates Filter implementation which didn't have this capability

Parameters:
filter -
name - column family name
Returns:
whether column family is essential

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


Copyright © 2013 The Apache Software Foundation. All Rights Reserved.