3

我使用 HappyBase 作为 Python Thrift 客户端来连接到 HBase。

我正在扫描表格,需要在多列上使用过滤器。如何在 HappyBase 中实现这一点?Java 使用 Filterlist 提供了一个选项。

4

1 回答 1

11

As specified on the github page, Happybase is using Thrift. You should use the same syntax as thrift.

On your scan function, you can specify a filter string :

SingleColumnValueFilter(‘’, ‘, , ‘’)

For example, if you need to scan all rows with the column blah:blouh = batman :

hbase_table.scan(filter="SingleColumnValueFilter ('blah','blouh',=,'regexstring:^batman$')")

You can use AND or OR to put several filters, just remember to surround everything with parenthesis.

Thrift Documentation : http://hbase.apache.org/book/thrift.html

Be careful when creating filters on string, you will have to use a specific comparator (like regexstring in my example).

于 2013-08-09T08:53:10.373 回答