Filters In Hbase Shell

Our HadoopTpoint App is now available in google play store,please rate and comment it in play store : W3Schools

 

Filters In Hbase Shell

Filters In Hbase Shell,Filter Language was introduced in APache HBase 0.92. It allows you to perform server-side filtering when accessing HBase over Thrift or in the HBase shell. You can find out more about shell integration by using the scan help command in the shell.

 Let us see list of filters available in hbase by using hbase command (show_filters)

command for list filters are available in hbase

KeyOnlyFilter

This filter does not take any arguments. It returns only the key component of each key-value.

Syntax

KeyOnlyFilter ()

Example of keyonlyfilter

FirstKeyOnlyFilter

This filter doesntt take any arguments. It returns only the first key-value from each row.

Syntax

FirstKeyOnlyFilter ()

Example of firstkeyonlyfilter

prefixfilter:

This filter takes one argument  a prefix of a row key. It returns only those key-values present in a row that starts with the specified row prefix

Syntax

PrefixFilter (<row_prefix>)

Example of prefixfilter

ColumnPrefixFilter

This filter takes one argument  a column prefix. It returns only those key-values present in a column that starts with the specified column prefix. The column prefix must be of the form qualifier

Syntax

ColumnPrefixFilter(<column_prefix>)

Example of columnprefixfilter

MultipleColumnPrefixFilter

This filter takes a list of column prefixes. It returns key-values that are present in a column that starts with any of the specified column prefixes. Each of the column prefixes must be of the form qualifier

Syntax

MultipleColumnPrefixFilter(‘<column_prefix>,<column_prefix>,….<column_prefix>)

Example of multiplecolumnprefixfilter

ColumnCountGetFilter

This filter takes one argument  a limit. It returns the first limit number of columns in the table.

Syntax

ColumnCountGetFilter(<limit>)

Example of columncountgetfilter

PageFilter

This filter takes one argument  a page size. It returns page size number of rows from the table.

Syntax

PageFilter (<page_size>)

Example of pagefilter

InclusiveStopFilter

This filter takes one argument  a row key on which to stop scanning. It returns all key-values present in rows up to and including the specified row.

Syntax

InclusiveStopFilter(<stop_row_key>)

Example of Inclusivestopfilter

Family Filter(Qualifier Filter)

This filter takes a compare operator and a comparator. It compares each qualifier name with the comparator using the compare operator and if the comparison returns true, it returns all the key-values in that column.

Syntax

QualifierFilter (<compareOp>, <qualifier_comparator>)

Example of FamilyFilter

ValueFilter

This filter takes a compare operator and a comparator. It compares each value with the comparator using the compare operator and if the comparison returns true, it returns that key-value.

Syntax

ValueFilter (<compareOp>,‘<value_comparator>’)

 

The above all filters are very basic filters in hbase shell

SingleColumnValueFilter

This filter takes a column family, a qualifier, a compare operator and a comparator. If the specified column is not found – all the columns of that row will be emitted. If the column is found and the comparison with the comparator returns true, all the columns of the row will be emitted. If the condition fails, the row will not be emitted.

This filter also takes two additional optional boolean arguments – filterIfColumnMissing and setLatestVersionOnly

If the filterIfColumnMissing flag is set to true the columns of the row will not be emitted if the specified column to check is not found in the row. The default value is false.

If the setLatestVersionOnly flag is set to false, it will test previous versions (timestamps) too. The default value is true.

These flags are optional and if you must set neither or both.

Syntax

SingleColumnValueFilter(‘<family>’,‘<qualifier>’, <compare operator>, ‘<comparator>’, <filterIfColumnMissing_boolean>, <latest_version_boolean>)

        SingleColumnValueFilter(‘<family>’, ‘<qualifier>, <compare operator>, ‘<comparator>’)

Comments

  1. mahantesh says:

    Thanks

  2. Hello! Why AND leads to huge performance degradation?
    scan ‘table’, {FILTER => “PrefixFilter(‘166.154.120.1′)”}
    160 row(s) in 0.8840 seconds
    scan ‘table’, {FILTER => “PrefixFilter(‘166.154.120.1′) AND ColumnPrefixFilter(‘SSL’)”}
    101 row(s) in 196.0920 seconds

Speak Your Mind

*