org.apache.hadoop.hbase.filter
Class RandomRowFilter

java.lang.Object
  extended by org.apache.hadoop.hbase.filter.Filter
      extended by org.apache.hadoop.hbase.filter.FilterBase
          extended by org.apache.hadoop.hbase.filter.RandomRowFilter

@InterfaceAudience.Public
@InterfaceStability.Stable
public class RandomRowFilter
extends FilterBase

A filter that includes rows based on a chance.


Nested Class Summary
 
Nested classes/interfaces inherited from class org.apache.hadoop.hbase.filter.Filter
Filter.ReturnCode
 
Field Summary
protected  float chance
           
protected  boolean filterOutRow
           
protected static Random random
           
 
Fields inherited from class org.apache.hadoop.hbase.filter.Filter
reversed
 
Constructor Summary
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(Cell v)
          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 FilterBase.filterKeyValue(Cell) 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()
           
 boolean hasFilterRow()
          Fitlers that never filter by modifying the returned List of Cells can inherit this implementation that does nothing.
static RandomRowFilter parseFrom(byte[] pbBytes)
           
 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.
 byte[] toByteArray()
          Return length 0 byte array for Filters that don't require special serialization
 
Methods inherited from class org.apache.hadoop.hbase.filter.FilterBase
createFilterFromArguments, filterRow, filterRowCells, getNextCellHint, getNextKeyHint, isFamilyEssential, toString, transform, transformCell
 
Methods inherited from class org.apache.hadoop.hbase.filter.Filter
isReversed, setReversed
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

random

protected static final Random random

chance

protected float chance

filterOutRow

protected boolean filterOutRow
Constructor Detail

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.

Overrides:
filterAllRemaining in class FilterBase
Returns:
true to end scan, false to continue.

filterKeyValue

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

Overrides:
filterKeyValue in class FilterBase
Parameters:
v - the Cell 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(Cell) can inherit this implementation that never filters a row.

Overrides:
filterRow in class FilterBase
Returns:
true to exclude row, false to include row.

hasFilterRow

public boolean hasFilterRow()
Description copied from class: FilterBase
Fitlers that never filter by modifying the returned List of Cells can inherit this implementation that does nothing.

Overrides:
hasFilterRow in class FilterBase
Returns:
True if this filter actively uses filterRow(List) or filterRow().

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).

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.

Overrides:
reset in class FilterBase

toByteArray

public byte[] toByteArray()
Description copied from class: FilterBase
Return length 0 byte array for Filters that don't require special serialization

Overrides:
toByteArray in class FilterBase
Returns:
The filter serialized using pb

parseFrom

public static RandomRowFilter parseFrom(byte[] pbBytes)
                                 throws DeserializationException
Parameters:
pbBytes - A pb serialized RandomRowFilter instance
Returns:
An instance of RandomRowFilter made from bytes
Throws:
DeserializationException
See Also:
toByteArray()


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