Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

doing a ValueFilter or a ColumnFilter on hbase shell

Tags:

hbase

Could anyone please tell me how to do a qualifier filter or ValueFilter from the hbase shell command line?

like image 904
user1534730 Avatar asked Sep 28 '12 05:09

user1534730


2 Answers

It is very similar to how you would code in any programming language, for instance :-

import org.apache.hadoop.hbase.filter.CompareFilter
import org.apache.hadoop.hbase.filter.SingleColumnValueFilter
import org.apache.hadoop.hbase.util.Bytes
scan 'tableName', {COLUMNS=>['CF:qualifier1', 'CF:qualifier2'], LIMIT=>10,
FILTER=>SingleColumnValueFilter.new(Bytes.toBytes('CF'),
Bytes.toBytes('qualifier1'), CompareFilter::CompareOp.valueOf('EQUAL'),
Bytes.toBytes('value'))}

You obviously have to change parameters depending on the fiter you use.

like image 200
sulabhc Avatar answered Oct 09 '22 02:10

sulabhc


You can instantiate any filter the same way you would do in Java (with JRuby syntax), and supply the filter as:

filter = ...
scan 'mytable', FILTER => filter

However, instantiating the filter in the shell directly can be cumbersome, so an easier way is to supply filter as a string using Filter Language. For example, to include all the columns with value equal to 'myvalue' in a scan you would use:

scan 'mytable', FILTER => "ValueFilter(=, 'binary:myvalue')"

You can check this document as a 'Filter Language' reference.

(edit for closing double quote)

like image 22
kirlich Avatar answered Oct 09 '22 02:10

kirlich