如何使用Stargate REST API在HBase中构建更复杂的过滤器层次结构?

时间:2016-06-05 16:44:32

标签: hbase stargate

样本表

  

HBase的(主):026:0>扫描'数据表'

     

ROW COLUMN + CELL

     

key1 column = cf1:col1,   timestamp = 1465135446446,value = value1

     

key1 column = cf1:col2,timestamp = 1465135452934,value = value1

     

key2 column = cf2:col1,timestamp = 1465135471613,value = value2

     

key2 column = cf2:col2,timestamp = 1465135481068,value = value2

     

key3 column = cf1:col1,timestamp = 1465137223212,value = value3

     

key3 column = cf2:col2,timestamp = 1465137232291,value = value3

     

在0.0300秒内完成3行

查询

  

过滤下面任何一个条件

的行      

行键为“key1”,其中Column为{cf1:col1}

     

OR

     

列是{cf2:col2}

预期产出

  

ROW COLUMN + CELL

     

key1 column = cf1:col1,timestamp = 1465135446446,value = value1

     

key2 column = cf2:col2,timestamp = 1465135481068,value = value2

     

key3 column = cf2:col2,timestamp = 1465137232291,value = value3

1 个答案:

答案 0 :(得分:1)

Base64等效

cf1 => Y2Yx

col1 => Y29sMQ==

key1 => a2V5MQ==

cf2=> Y2Yy

col2 => Y29sMg==

  

运营商(op):LESS,LESS_OR_EQUAL,EQUAL,NOT_EQUAL,GREATER_OR_EQUAL,GREATER,NO_OP;

     

FILTER LIST(op):MUST_PASS_ALL,MUST_PASS_ONE

{
    "type": "FilterList",
    "op": "MUST_PASS_ONE",
    "filters": [{
        "type": "FilterList",
        "op": "MUST_PASS_ALL",
        "filters": [{
            "type": "FamilyFilter",
            "op": "EQUAL",
            "comparator": {
                "type": "BinaryComparator",
                "value": "Y2Yx"
            }
        }, {
            "type": "QualifierFilter",
            "op": "EQUAL",
            "comparator": {
                "type": "BinaryComparator",
                "value": "Y29sMQ =="
            }
        }, {
            "type": "RowFilter",
            "op": "EQUAL",
            "comparator": {
                "type": "BinaryComparator",
                "value": "a2V5MQ=="
            }
        }]
    }, {
        "type": "FilterList",
        "op": "MUST_PASS_ALL",
        "filters": [{
            "type": "FamilyFilter",
            "op": "EQUAL",
            "comparator": {
                "type": "BinaryComparator",
                "value": "Y2Yy"
            }
        }, {
            "type": "QualifierFilter",
            "op": "EQUAL",
            "comparator": {
                "type": "BinaryComparator",
                "value": "Y29sMg=="
            }
        }]
    }]
}

$ curl -i -H" Content-Type:text / xml" -d @ complex_filter.txt http://shva1.hwxblr.com:9292/datatable/scanner

HTTP / 1.1 201已创建 地点:http://shva1.hwxblr.com:9292/datatable/scanner/146513894809742c1664a

样本输出

$ curl -i -H"接受:application / json" http://shva1.hwxblr.com:9292/datatable/scanner/146513894809742c1664a

  

{"行":[{"键":" a2V5MQ ==""细胞":[{&#34 ;柱":" Y2YxOmNvbDE =""时间戳":1465135446446," $":" dmFsdWUx"}]}, {"键":" a2V5Mg ==""细胞":[{"柱":" Y2YyOmNvbDI =&# 34;,"时间戳":1465135481068," $":" dmFsdWUy"}]},{"键":" a2V5Mw ==""细胞":[{"柱":" Y2YyOmNvbDI =""时间戳":1465137232291, " $":" dmFsdWUz"}]}]}