zoukankan      html  css  js  c++  java
  • HBase shell scan 过滤器用法总结

    比较器:
    前面例子中的regexstring:2014-11-08.*、binary:x00x00x00x05,这都是比较器。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:x00x00x00x00x00x00x00x0F') )"  
    
    scan 'obd:journey', LIMIT => 10, FILTER=>"(ValueFilter(>,'binary:x00x00x02x81') AND ValueFilter(<,'binary:x00x00x02x82'))"
    
    scan 'obd:journey', LIMIT => 10, FILTER=>"(RowFilter(>,'binary:x00x00x02x81') AND RowFilter(<,'binary:x00x00x02x82'))"
    
    echo "scan 'obd:journey', FILTER=>"(RowFilter(>,'binary:x00x00x02x81'))"" | ./hbase shell > ~/journey.txt
    
    
    echo "scan 'obd:journey', FILTER=>"(RowFilter(=,'binaryprefix:x00x00x02x81'))"" | ./hbase shell > ~/journey.txt
    
    
    echo "scan 'obd:journey', FILTER=>"(RowFilter(>=,'binaryprefix:x00x00x02x81x00x00x00x00x00x00x00x00'))"" | ./hbase shell > ~/journey.txt
    
    echo "scan 'obd:journey', FILTER=>"(RowFilter(>=,'binaryprefix:x00x00x00x81x00x00x00x00x00x00x00x00'))"" | ./hbase shell > ~/journey.txt
    
    scan 'obd:journey', FILTER=>"(RowFilter(>,'binary:x00x00x02x81x00x00x00x00x00x00x00x00'))"
    
    
    echo "scan 'obd:journey', FILTER=>"(RowFilter(>,'binaryprefix:x00x00x02x81x00x00x00x00x00x00x00x00') AND RowFilter(<,'binaryprefix:x00x00x02x82x00x00x00x00x00x00x00x00'))"" | ./hbase shell > ~/journey.txt
  • 相关阅读:
    POJ 1182 食物链
    HDU 1385 Minimum Transport Cost
    HDU_2544 最短路
    HDU 2066 一个人的旅行
    poj3090
    poj3157
    poj3169
    poj3125
    poj3187
    VMware Workstation 8的简明使用教程
  • 原文地址:https://www.cnblogs.com/hyl8218/p/10058873.html
Copyright © 2011-2022 走看看