HBase shell scan 過濾器用法總結


比較器:
前面例子中的regexstring:2014-11-08.*、binary:\x00\x00\x00\x05,這都是比較器。HBase的filter有四種比較器:
(1)二進制比較器:如’binary:abc’,按字典排序跟’abc’進行比較
(2)二進制前綴比較器:如’binaryprefix:abc’,按字典順序只跟’abc’比較前3個字符
(3)正則表達式比較器:如’regexstring:ab*yz’,按正則表達式匹配以ab開頭,以yz結尾的值。這個比較器只能使用=、!=兩個比較運算符。
(4)子串比較器:如’substring:abc123’,匹配以abc123開頭的值。這個比較順也只能使用=、!=兩個比較運算符。

比較運算符:
HBase的filter中有7個比較運算符

1. LESS (<)

2. LESS_OR_EQUAL (<=)

3. EQUAL (=)

4. NOT_EQUAL (!=)

5. GREATER_OR_EQUAL (>=)

6. GREATER (>)

7. NO_OP (no operation)(不知道這個怎么用)

如果需要再bash直接執行查詢,可以使用一下方式

echo "scan 'testByCrq', FILTER=>\"ValueFilter(=,'substring:111')\"" | hbase shell

幾個例子

scan 'obd:journey', LIMIT => 10, FILTER=>"(ValueFilter(>,'binary:\x00\x00\x00\x00\x00\x00\x00\x0F') )"  

scan 'obd:journey', LIMIT => 10, FILTER=>"(ValueFilter(>,'binary:\x00\x00\x02\x81') AND ValueFilter(<,'binary:\x00\x00\x02\x82'))"

scan 'obd:journey', LIMIT => 10, FILTER=>"(RowFilter(>,'binary:\x00\x00\x02\x81') AND RowFilter(<,'binary:\x00\x00\x02\x82'))"

echo "scan 'obd:journey', FILTER=>\"(RowFilter(>,'binary:\x00\x00\x02\x81'))\"" | ./hbase shell > ~/journey.txt


echo "scan 'obd:journey', FILTER=>\"(RowFilter(=,'binaryprefix:\x00\x00\x02\x81'))\"" | ./hbase shell > ~/journey.txt


echo "scan 'obd:journey', FILTER=>\"(RowFilter(>=,'binaryprefix:\x00\x00\x02\x81\x00\x00\x00\x00\x00\x00\x00\x00'))\"" | ./hbase shell > ~/journey.txt

echo "scan 'obd:journey', FILTER=>\"(RowFilter(>=,'binaryprefix:\x00\x00\x00\x81\x00\x00\x00\x00\x00\x00\x00\x00'))\"" | ./hbase shell > ~/journey.txt

scan 'obd:journey', FILTER=>"(RowFilter(>,'binary:\x00\x00\x02\x81\x00\x00\x00\x00\x00\x00\x00\x00'))"


echo "scan 'obd:journey', FILTER=>\"(RowFilter(>,'binaryprefix:\x00\x00\x02\x81\x00\x00\x00\x00\x00\x00\x00\x00') AND RowFilter(<,'binaryprefix:\x00\x00\x02\x82\x00\x00\x00\x00\x00\x00\x00\x00'))\"" | ./hbase shell > ~/journey.txt

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM