HBase Filter Language in PHP with Thrift

我们两清 提交于 2019-12-08 08:10:25

问题


I'm looking for a way to use the HBase Filter Language in PHP.

The HBase Book's chapter on Thrift seems formal and provides some filters for user to access HBase in PHP. A sample PHP code are also provided in this page, but I can not find any APIs in thrift (such as $client->scannerOpenWithFilterString(...)). I even checked the thrift definition file for HBase 0.92.0, but it has no interface for scannerOpenWithFilterString.

Versions used: Hadoop 0.20.203.0, Hbase 0.90.4 and thrift 0.8.0.

Does anyone know how to use PHP with filter features to access HBase?


回答1:


Hbase filters for Thrift API were implemented in v.0.92 There's a function named scannerOpenWithScan(), which takes 2 parameters - table name and TScan object.

You need to generate php classes for thrift using Hbase.thrift file, provided in hbase 0.92+ release

thrift -gen php Hbase.thrift 

In TScan object you can set startRow, stopRow, timestamp, columns, caching and filterString - which is exactly what you need.

Example: get rows 00100, 00200 and 00300

$flt = "RowFilter(=, 'regexstring:00[1-3]00')";
$scan = new TScan(array("filterString" => $flt));

or

$scan = new TScan();
$scan->setFilterString($flt);

and finally

$scanner = $client->scannerOpenWithScan("table_name", $scan);
while ($result = $client->scannerGet($scanner)) {
  ...
}

For information about filterString syntax and available filters see attachments here: https://issues.apache.org/jira/browse/HBASE-4176



来源:https://stackoverflow.com/questions/8633540/hbase-filter-language-in-php-with-thrift

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!