hbase过滤器

1、值过滤器(ValueFilter)

谁的值=bbbb

hbase(main):008:0> scan ‘t2’,FILTER=>”ValueFilter(=,’binary:bbbb’)”

谁的值包含bbb

hbase(main):010:0> scan ‘t2’,FILTER=>”ValueFilter(=,’substring:bbb’)”

2、列过滤器(ColumnPrefixFilter)

column为b值包含ac

hbase(main):017:0> scan ‘t2’,FILTER=>”ColumnPrefixFilter(‘b’) AND ValueFilter(=,’substring:ac’)”

column为b值包含aa或cc
hbase(main):003:0>scan ‘t2’,FILTER=>”ColumnPrefixFilter(‘b’) AND (ValueFilter(=,’substring:aa’) OR ValueFilter(=,’substring:cc’))”

3、行过滤器

row key以cn开头

hbase(main):014:0> scan ‘t2’,FILTER=>”PrefixFilter(‘cn’)”

从user1|ts2开始,找到所有的rowkey以user1开头的

hbase(main):025:0> scan ‘t2’,STARTROW=>’user1|ts3’,FILTER=>”PrefixFilter(‘user1’)”

从user1|ts2开始,找到所有rowkey以user2|ts4结束的

hbase(main):031:0> scan ‘t2’,STARTROW=>’user1|ts3’,STOPROW=>’user2|ts4’

查询rowkey中包含ts的

import org.apache.hadoop.hbase.filter.CompareFilter
import org.apache.hadoop.hbase.filter.SubstringComparator
import org.apache.hadoop.hbase.filter.RowFilter
hbase(main):039:0> scan ‘t2’,FILTER=>RowFilter.new(CompareFilter::CompareOp.valueOf(‘EQUAL’),SubstringComparator.new(‘ts’))

查询rowkey里面以user开头的,符合正则表达式的结果

import org.apache.hadoop.hbase.filter.RegexStringComparator
import org.apache.hadoop.hbase.filter.CompareFilter
import org.apache.hadoop.hbase.filter.SubstringComparator
import org.apache.hadoop.hbase.filter.RowFilter
hbase(main):010:0> scan ‘t2’,FILTER=>RowFilter.new(CompareFilter::CompareOp.valueOf(‘EQUAL’),RegexStringComparator.new(‘^user\d+|ts\d+$’))

4、时间戳过滤器

hbase(main):014:0> scan ‘t2’,FILTER=>”TimestampsFilter(1409559455702,1409562905630,1407982676242)”