org.apache.hadoop.hbase.filter
Class RegExpRowFilter

java.lang.Object
  extended by org.apache.hadoop.hbase.filter.RegExpRowFilter
All Implemented Interfaces:
RowFilterInterface, Writable

public class RegExpRowFilter
extends Object
implements RowFilterInterface

Implementation of RowFilterInterface that can filter by rowkey regular expression and/or individual column values (equals comparison only). Multiple column filters imply an implicit conjunction of filter criteria.


Constructor Summary
RegExpRowFilter()
          Default constructor, filters nothing.
RegExpRowFilter(String rowKeyRegExp)
          Constructor that takes a row key regular expression to filter on.
RegExpRowFilter(String rowKeyRegExp, Map<Text,byte[]> columnFilter)
          Constructor that takes a row key regular expression to filter on.
 
Method Summary
 void acceptedRow(Text key)
          Called to let filter know that the specified row has been included in the results (passed all filtering).
 boolean filter(Text rowKey)
          Filters on just a row key.
 boolean filter(Text rowKey, Text colKey, byte[] data)
          Filters on row key and/or a column key.
 boolean filterAllRemaining()
          Determines if the filter has decided that all remaining results should be filtered (skipped).
 boolean filterNotNull(TreeMap<Text,byte[]> columns)
          Filters row if given columns are non-null and have null criteria or if there exists criteria on columns not included in the column set.
 void readFields(DataInput in)
          Reads the fields of this object from in.
 void reset()
          Resets the state of the filter.
 void setColumnFilter(Text colKey, byte[] value)
          Specify a value that must be matched for the given column.
 void setColumnFilters(Map<Text,byte[]> columnFilter)
          Set column filters for a number of columns.
 void validate(Text[] columns)
          Validates that this filter applies only to a subset of the given columns.
 void write(DataOutput out)
          Writes the fields of this object to out.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RegExpRowFilter

public RegExpRowFilter()
Default constructor, filters nothing. Required though for RPC deserialization.


RegExpRowFilter

public RegExpRowFilter(String rowKeyRegExp)
Constructor that takes a row key regular expression to filter on.

Parameters:
rowKeyRegExp -

RegExpRowFilter

public RegExpRowFilter(String rowKeyRegExp,
                       Map<Text,byte[]> columnFilter)
Constructor that takes a row key regular expression to filter on.

Parameters:
rowKeyRegExp -
columnFilter -
Method Detail

acceptedRow

public void acceptedRow(Text key)
Called to let filter know that the specified row has been included in the results (passed all filtering). With out HScanner calling this, the filter does not know if a row passed filtering even if it passed the row itself because other filters may have failed the row. E.g. when this filter is a member of a RowFilterSet with an OR operator.

Specified by:
acceptedRow in interface RowFilterInterface
See Also:
RowFilterSet

setColumnFilter

public void setColumnFilter(Text colKey,
                            byte[] value)
Specify a value that must be matched for the given column.

Parameters:
colKey - the column to match on
value - the value that must equal the stored value.

setColumnFilters

public void setColumnFilters(Map<Text,byte[]> columnFilter)
Set column filters for a number of columns.

Parameters:
columnFilter - Map of columns with value criteria.

reset

public void reset()
Resets the state of the filter. Used prior to the start of a Region scan.

Specified by:
reset in interface RowFilterInterface

filterAllRemaining

public boolean filterAllRemaining()
Determines if the filter has decided that all remaining results should be filtered (skipped). This is used to prevent the scanner from scanning a the rest of the HRegion when for sure the filter will exclude all remaining rows.

Specified by:
filterAllRemaining in interface RowFilterInterface
Returns:
true if the filter intends to filter all remaining rows.

filter

public boolean filter(Text rowKey)
Filters on just a row key.

Specified by:
filter in interface RowFilterInterface
Returns:
true if given row key is filtered and row should not be processed.

filter

public boolean filter(Text rowKey,
                      Text colKey,
                      byte[] data)
Filters on row key and/or a column key.

Specified by:
filter in interface RowFilterInterface
Parameters:
rowKey - row key to filter on. May be null for no filtering of row key.
colKey - column whose data will be filtered
data - column value
Returns:
true if row filtered and should not be processed.

filterNotNull

public boolean filterNotNull(TreeMap<Text,byte[]> columns)
Filters row if given columns are non-null and have null criteria or if there exists criteria on columns not included in the column set. A column is considered null if it:

Specified by:
filterNotNull in interface RowFilterInterface
Returns:
true if null/non-null criteria not met.

readFields

public void readFields(DataInput in)
                throws IOException
Reads the fields of this object from in. For efficiency, implementations should attempt to re-use storage in the existing object where possible.

Specified by:
readFields in interface Writable
Throws:
IOException

validate

public void validate(Text[] columns)
Validates that this filter applies only to a subset of the given columns. This check is done prior to opening of scanner due to the limitation that filtering of columns is dependent on the retrieval of those columns within the HRegion. Criteria on columns that are not part of a scanner's column list will be ignored. In the case of null value filters, all rows will pass the filter. This behavior should be 'undefined' for the user and therefore not permitted.

Specified by:
validate in interface RowFilterInterface

write

public void write(DataOutput out)
           throws IOException
Writes the fields of this object to out.

Specified by:
write in interface Writable
Throws:
IOException


Copyright © 2006 The Apache Software Foundation