2
我在安装HBase集群时试图通过Stargate REST接口访问数据。大多数只读函数(即列表表,获取版本,元数据等)都很好地工作。但是,我实际上将数据插入到创建的任何表中时遇到问题。这里就是我这么远....如何使用PHP Stargate客户端将数据插入到Hbase表中
创建一个虚拟表有两列,具体如下:
$table_schema = <<<SCHEMA
<TableSchema name="mytable" IS_META="false" IS_ROOT="false">
<ColumnSchema name="info" BLOCKSIZE="65536" BLOOMFILTER="false" BLOCKCACHE="false" COMPRESSION="NONE" LENGTH="2147483647" VERSIONS="1" TTL="-1" IN_MEMORY="false" />
<ColumnSchema name="url" BLOCKSIZE="65536" BLOOMFILTER="false" BLOCKCACHE="false" COMPRESSION="NONE" LENGTH="2147483647" VERSIONS="1" TTL="-1" IN_MEMORY= "false"/>
</TableSchema>
SCHEMA;
require_once "HTTP/Request.php";
$request = new HTTP_Request("http://localhost:8080");
$request->setMethod(HTTP_REQUEST_METHOD_PUT);
$request->addHeader("Accept", "text/xml");
$request->addHeader("Accept", "text/xml");
$request->setBody($table_schema);
$request->sendRequest();
表创建工作正常。接下来,我想插入一些数据到我的新表中。以下是我试图做到这一点:
$row_key = base64_encode("higgilty");
$column_name = base64_encode("info");
$value = base64_encode("Here is a test value");
$data = <<<DATA
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<CellSet>
<Row key="$row_key">
<Cell column="$column_name">
$value
</Cell>
</Row>
</CellSet>
DATA;
require_once "HTTP/Request.php";
$request = new HTTP_Request("http://localhost:8080/mytable/higgilty");
$request->setMethod(HTTP_REQUEST_METHOD_PUT);
$request->addHeader("Accept", "text/xml");
$request->addHeader("Accept", "text/xml");
$request->setBody($data);
$request->sendRequest();
这个请求的结果返回503错误,但下列情况除外:
[...] org.apache.hadoop.hbase.regionserver.NoSuchColumnFamilyException: Column family does not exist in region [...]
的错误是很清楚,但我不知道是什么上面发布的模式错误。
我还想知道如果我使用Thrift软件包并生成必要的PHP客户端文件而不是使用Starbase更好吗?如果有人有任何这方面的经验,我很乐意听到你的消息。
任何帮助,非常感谢。
自从我张贴这篇文章已经有一段时间了,但是感谢您花时间回答! – sayajay 2010-07-09 18:20:51