org.apache.hadoop.hbase.filter
Class RandomRowFilter

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

public class RandomRowFilter
extends FilterBase

A filter that includes rows based on a chance.


Nested Class Summary
 
Nested classes/interfaces inherited from interface org.apache.hadoop.hbase.filter.Filter
Filter.ReturnCode
 
Field Summary
protected  float chance
           
protected  boolean filterOutRow
           
protected static Random random
           
 
Constructor Summary
RandomRowFilter()
          Writable constructor, do not use.
RandomRowFilter(float chance)
          Create a new filter with a specified chance for a row to be included.
 
Method Summary
 boolean filterAllRemaining()
          Filters that never filter all remaining can inherit this implementation that never stops the filter early.
 Filter.ReturnCode filterKeyValue(KeyValue v)
          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 FilterBase.filterKeyValue(KeyValue) can inherit this implementation that never filters a row.
 boolean filterRowKey(byte[] buffer, int offset, int length)
          Filters that do not filter by row key can inherit this implementation that never filters anything.
 float getChance()
           
 void readFields(DataInput in)
           
 void reset()
          Filters that are purely stateless and do nothing in their reset() methods can inherit this null/empty implementation.
 void setChance(float chance)
          Set the chance that a row is included.
 void write(DataOutput out)
           
 
Methods inherited from class org.apache.hadoop.hbase.filter.FilterBase
createFilterFromArguments, filterRow, getNextKeyHint, hasFilterRow, transform
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

random

protected static final Random random

chance

protected float chance

filterOutRow

protected boolean filterOutRow
Constructor Detail

RandomRowFilter

public RandomRowFilter()
Writable constructor, do not use.


RandomRowFilter

public RandomRowFilter(float chance)
Create a new filter with a specified chance for a row to be included.

Parameters:
chance -
Method Detail

getChance

public float getChance()
Returns:
The chance that a row gets included.

setChance

public void setChance(float chance)
Set the chance that a row is included.

Parameters:
chance -

filterAllRemaining

public boolean filterAllRemaining()
Description copied from class: FilterBase
Filters that never filter all remaining can inherit this implementation that never stops the filter early.

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

filterKeyValue

public Filter.ReturnCode filterKeyValue(KeyValue v)
Description copied from class: FilterBase
Filters that dont filter by key value can inherit this implementation that includes all KeyValues.

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

filterRow

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

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

filterRowKey

public boolean filterRowKey(byte[] buffer,
                            int offset,
                            int length)
Description copied from class: FilterBase
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
Overrides:
filterRowKey in class FilterBase
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).

reset

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

Specified by:
reset in interface Filter
Overrides:
reset in class FilterBase

readFields

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

write

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


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