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