本文介绍了使用Thrift的PHP中的HBase过滤器语言的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



HBase Book的,但它没有 scannerOpenWithFilterString 的接口。 p>

使用的版本: Hadoop 0.20.203.0 Hbase 0.90.4 thrift 0.8.0



有谁知道如何使用带过滤器功能的PHP来访问HBase?

解决方案

用于Thrift API的Hbase过滤器在v.0.92中实现
有一个名为scannerOpenWithScan()的函数,参数 - 表名和TScan对象。



您需要使用hbase.thrift文件生成php类,以便在hbase 0.92+版本中提供。

  thrift -gen php Hbase.thrift 



在TScan对象中,您可以设置startRow,stopRow,时间戳,列c aching和filterString - 这正是你需要的。



示例:get rows 00100,00200 and 00300

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

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

最后

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

有关filterString语法和可用过滤器的信息,请参阅附件:


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?

解决方案

Hbase filters for Thrift API were implemented in v.0.92There'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

这篇关于使用Thrift的PHP中的HBase过滤器语言的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-20 01:19