The Filter Filter

HBase filters are classified into three types: cell filter, row key filter, column filter, and decorator filter

Cell filter

ValueFilter ValueFilter

The data is filtered based on the values of all the cells, and the final result contains the results of all the columns that passed through the filter

new ValueFilter(CompareOperator, Comparable);
Copy the code

SingleColumnValueFilter Single-column value filter

Filters data based on the specified column family, column values

new SingleColumnValueFilter(family, column, CompareOperator, value);
new SingleColumnValueFilter(family, column, CompareOperator, ByteArrayComparable);
Copy the code

Cons: If a row has no columns to compare, row change data is included in the result, so make sure all rows contain columns to compare, or use a filter list

TimestampsFilter Indicates the timestamp filter

Matches the records of the specified timestamp exactly

List<Long> list = new ArrayList<>();
list.add(1L);
list.add(5L);
new TimestampsFilter(list);
Copy the code

Row key filter

RowFilter Indicates the row key filter

new RowFilter(CompareOperator, Comparable);
Copy the code

MultiRowRangeFilter Multiline range filter

Specify a range of row keys for searching

new MultiRowRangeFilter(List<RowRange> list);
new RowRange(byte[] startRow, boolean startRowInclusive, byte[] stopRow, boolean stopRowInclusive);
Copy the code

PrefixFilter line key PrefixFilter

new PrefixFilter(byte[] rowPrefix);
Copy the code

FuzzyRowFilter Fuzzy row key filter

new FuzzyRowFilter(List<Pair<byte[].byte[]>> pairs);
// Line key: Enter the keyword to be matched, blur the position of the character to be matched, use any character instead.
// Line key mask: an array of bytes, the same length as the keyword, with 1 in the position of the character to be fuzzy matched and 0 in other positions
Copy the code

InclusiveStopFilter Contains the end filter

new InlusiveStopFilter(byte[] rowKey);
Copy the code

RandomRowFilter RandomRowFilter

new RandomRowFilter(float chance);
// As the scanner traverses the data, it generates a random value, which is compared to chance. If it is smaller than chance, the line is included in the final result. Chance ranges from 0.0 to 1.0. If chance is negative, all rows are filtered out, and if chance is greater than 1, all rows are included in the result
Copy the code

The column filter

FamilyFilter column FamilyFilter

new FamilyFilter(CompareOperator, Comparable);
Copy the code

QualifierFilter Column filter

new QulifierFilter(CompareOperator, Comparable);
Copy the code

DependentColumnFilter Dependent filter

Specify a column as a dependent column and use the timestamp of the dependent column as the filtering criterion. Other columns whose timestamps are larger than the timestamp of the dependent column will be filtered out

new DependentColumnFilter(byte[] family, byte[] column, boolean dropDependentColumn);
Copy the code

PrefixColumnFilter Column prefix filter

new PrefixColumnFilter(byte[] columnPrefix);
Copy the code

MultiColumnPrefixFilter Multi-column prefix filter

new MultiColumnPrefixFilter(byte[] []);Copy the code

KeyOnlyFilter Column key filter

When traversing the data, only the column name is retrieved, not the value

new KeyOnlyFilter();
Copy the code

FirstKeyOnlyFilter First column check filter

Based on KeyOnlyFilter, each row is traversed only to the first column

new FirstKeyOnlyFilter();
Copy the code

ColumnRangeFilter Column name range filter

new ColumnRangeFilter(byte[] minColumn, boolean minColumnInclusive, byte[] maxColumn, boolean maxColumnInclusive);
Copy the code

ColumnCountGetFilter Number of columns filter

Used for Get operations

new ColumnCountFilter(int count)
Copy the code

Decorative filter

SkipFilter Indicates the forward filter

When the wrapped filter encounters a KeyValue that needs to be filtered, the entire row is skipped

ValueFilter vFilter = new ValueFilter();
new SkipFilter(vFilter);
Copy the code

WhileMatchFilter Full matching filter

Wrap a filter, and when one of the wrapped filters encounters a KeyValue that needs to be filtered, the entire scan stops

CompareOperator comparison

LESS: LESS than

LEFF_OR_EQUAL: less than or equal to

Is EQUAL to EQUAL:

NOT_EQUAL: not equal to

GREATER.

GREATER_EQUAL: indicates that the value must be greater than or equal to

NO_OP: no operation is performed

The Comparable comparator

SubstringComparator

Checks whether the target string contains the specified string, matched with EQUAL, NOT_EQUAL

BinaryComparator

Determines whether the target value is equal to, greater than or less than the specified value, string

RegexStringComparator

A regular expression is used to match a string with the comparison EQUAL

NullComparator

Null-valued comparator, matched with a comparison of EQUAL, NOT_EQUAL

LongComparator

Digital comparator

BitComparator

Bit bit comparator

BinaryPrefixComparator

Byte array prefix comparator that compares records that begin with a specified byte array