org.apache.hadoop.hbase.hbql.filter
Class SingleColumnValueFilter

java.lang.Object
  extended by org.apache.hadoop.hbase.filter.FilterBase
      extended by org.apache.hadoop.hbase.hbql.filter.InstrumentedFilter
          extended by org.apache.hadoop.hbase.hbql.filter.SingleColumnValueFilter
All Implemented Interfaces:
org.apache.hadoop.hbase.filter.Filter, org.apache.hadoop.io.Writable

public class SingleColumnValueFilter
extends InstrumentedFilter

This filter is used to filter cells based on value. It takes a CompareFilter.CompareOp operator (equal, greater, not equal, etc), and either a byte [] value or a WritableByteArrayComparable.

If we have a byte [] value then we just do a lexicographic compare. For example, if passed value is 'b' and cell has 'a' and the compare operator is LESS, then we will filter out this cell (return true). If this is not sufficient (eg you want to deserialize a long and then compare it to a fixed long value), then you can pass in your own comparator instead.

You must also specify a family and qualifier. Only the value of this column will be tested.

To prevent the entire row from being emitted if the column is not found on a row, use setFilterIfMissing(boolean). Otherwise, if the column is found, the entire row will be emitted only if the value passes. If the value fails, the row will be filtered out.

In order to test values of previous versions (timestamps), set setLatestVersionOnly(boolean) to false. The default is true, meaning that only the latest version's value is tested and all previous versions are ignored.

To filter based on the value of all scanned columns, use ValueFilter.


Nested Class Summary
 
Nested classes/interfaces inherited from interface org.apache.hadoop.hbase.filter.Filter
org.apache.hadoop.hbase.filter.Filter.ReturnCode
 
Constructor Summary
SingleColumnValueFilter()
          Writable constructor, do not use.
SingleColumnValueFilter(byte[] family, byte[] qualifier, org.apache.hadoop.hbase.filter.CompareFilter.CompareOp compareOp, byte[] value)
          Constructor for binary compare of the value of a single column.
SingleColumnValueFilter(byte[] family, byte[] qualifier, org.apache.hadoop.hbase.filter.CompareFilter.CompareOp compareOp, org.apache.hadoop.hbase.filter.WritableByteArrayComparable comparator)
          Constructor for binary compare of the value of a single column.
 
Method Summary
 boolean filterAllRemaining()
           
 org.apache.hadoop.hbase.filter.Filter.ReturnCode filterKeyValue(org.apache.hadoop.hbase.KeyValue keyValue)
           
 boolean filterRow()
           
 boolean filterRowKey(byte[] rowKey, int offset, int length)
           
 boolean getFilterIfMissing()
          Get whether entire row should be filtered if column is not found.
 boolean getLatestVersionOnly()
          Get whether only the latest version of the column value should be compared.
 boolean getVerbose()
           
 void readFields(DataInput in)
           
 void reset()
           
 void setFilterIfMissing(boolean filterIfMissing)
          Set whether entire row should be filtered if column is not found.
 void setLatestVersionOnly(boolean latestVersionOnly)
          Set whether only the latest version of the column value should be compared.
 void setVerbose(boolean verbose)
           
 void write(DataOutput out)
           
 
Methods inherited from class org.apache.hadoop.hbase.filter.FilterBase
filterRow, getNextKeyHint, hasFilterRow
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SingleColumnValueFilter

public SingleColumnValueFilter()
Writable constructor, do not use.


SingleColumnValueFilter

public SingleColumnValueFilter(byte[] family,
                               byte[] qualifier,
                               org.apache.hadoop.hbase.filter.CompareFilter.CompareOp compareOp,
                               byte[] value)
Constructor for binary compare of the value of a single column. If the column is found and the condition passes, all columns of the row will be emitted. If the column is not found or the condition fails, the row will not be emitted.

Parameters:
family - name of column family
qualifier - name of column qualifier
compareOp - operator
value - value to compare column values against

SingleColumnValueFilter

public SingleColumnValueFilter(byte[] family,
                               byte[] qualifier,
                               org.apache.hadoop.hbase.filter.CompareFilter.CompareOp compareOp,
                               org.apache.hadoop.hbase.filter.WritableByteArrayComparable comparator)
Constructor for binary compare of the value of a single column. If the column is found and the condition passes, all columns of the row will be emitted. If the condition fails, the row will not be emitted.

Use the filterIfColumnMissing flag to set whether the rest of the columns in a row will be emitted if the specified column to check is not found in the row.

Parameters:
family - name of column family
qualifier - name of column qualifier
compareOp - operator
comparator - Comparator to use.
Method Detail

setVerbose

public void setVerbose(boolean verbose)
Specified by:
setVerbose in class InstrumentedFilter

getVerbose

public boolean getVerbose()
Specified by:
getVerbose in class InstrumentedFilter

filterRowKey

public boolean filterRowKey(byte[] rowKey,
                            int offset,
                            int length)
Specified by:
filterRowKey in interface org.apache.hadoop.hbase.filter.Filter
Overrides:
filterRowKey in class org.apache.hadoop.hbase.filter.FilterBase

filterKeyValue

public org.apache.hadoop.hbase.filter.Filter.ReturnCode filterKeyValue(org.apache.hadoop.hbase.KeyValue keyValue)
Specified by:
filterKeyValue in interface org.apache.hadoop.hbase.filter.Filter
Overrides:
filterKeyValue in class org.apache.hadoop.hbase.filter.FilterBase

filterAllRemaining

public boolean filterAllRemaining()
Specified by:
filterAllRemaining in interface org.apache.hadoop.hbase.filter.Filter
Overrides:
filterAllRemaining in class org.apache.hadoop.hbase.filter.FilterBase

filterRow

public boolean filterRow()
Specified by:
filterRow in interface org.apache.hadoop.hbase.filter.Filter
Overrides:
filterRow in class org.apache.hadoop.hbase.filter.FilterBase

reset

public void reset()
Specified by:
reset in interface org.apache.hadoop.hbase.filter.Filter
Overrides:
reset in class org.apache.hadoop.hbase.filter.FilterBase

getFilterIfMissing

public boolean getFilterIfMissing()
Get whether entire row should be filtered if column is not found.

Returns:
true if row should be skipped if column not found, false if row should be let through anyways

setFilterIfMissing

public void setFilterIfMissing(boolean filterIfMissing)
Set whether entire row should be filtered if column is not found.

If true, the entire row will be skipped if the column is not found.

If false, the row will pass if the column is not found. This is default.


getLatestVersionOnly

public boolean getLatestVersionOnly()
Get whether only the latest version of the column value should be compared. If true, the row will be returned if only the latest version of the column value matches. If false, the row will be returned if any version of the column value matches. The default is true.


setLatestVersionOnly

public void setLatestVersionOnly(boolean latestVersionOnly)
Set whether only the latest version of the column value should be compared. If true, the row will be returned if only the latest version of the column value matches. If false, the row will be returned if any version of the column value matches. The default is true.


readFields

public void readFields(DataInput in)
                throws IOException
Throws:
IOException

write

public void write(DataOutput out)
           throws IOException
Throws:
IOException


Copyright © 2011. All Rights Reserved.