public class RandomRowFilter extends FilterBase
Filter.ReturnCode
Modifier and Type | Field and Description |
---|---|
protected float |
chance |
protected boolean |
filterOutRow |
protected static Random |
random |
Constructor and Description |
---|
RandomRowFilter()
Writable constructor, do not use.
|
RandomRowFilter(float chance)
Create a new filter with a specified chance for a row to be included.
|
Modifier and Type | Method and Description |
---|---|
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) |
createFilterFromArguments, filterRow, getNextKeyHint, hasFilterRow, isFamilyEssential, isFamilyEssential, toString, transform
protected static final Random random
protected float chance
protected boolean filterOutRow
public RandomRowFilter()
public RandomRowFilter(float chance)
chance
- public float getChance()
public void setChance(float chance)
chance
- public boolean filterAllRemaining()
FilterBase
filterAllRemaining
in interface Filter
filterAllRemaining
in class FilterBase
public Filter.ReturnCode filterKeyValue(KeyValue v)
FilterBase
filterKeyValue
in interface Filter
filterKeyValue
in class FilterBase
v
- the KeyValue in questionFilter.ReturnCode
public boolean filterRow()
FilterBase
FilterBase.filterKeyValue(KeyValue)
can inherit this implementation that
never filters a row.filterRow
in interface Filter
filterRow
in class FilterBase
public boolean filterRowKey(byte[] buffer, int offset, int length)
FilterBase
filterRowKey
in interface Filter
filterRowKey
in class FilterBase
buffer
- buffer containing row keyoffset
- offset into buffer where row key startslength
- length of the row keypublic void reset()
FilterBase
reset
in interface Filter
reset
in class FilterBase
public void readFields(DataInput in) throws IOException
IOException
public void write(DataOutput out) throws IOException
IOException
Copyright © 2014 The Apache Software Foundation. All Rights Reserved.