Skip to content

Instantly share code, notes, and snippets.

@maimai-swap
Created April 19, 2013 09:06
Show Gist options
  • Select an option

  • Save maimai-swap/5419098 to your computer and use it in GitHub Desktop.

Select an option

Save maimai-swap/5419098 to your computer and use it in GitHub Desktop.
hbase-0.92.2にphp経由でアクセスするスクリプト
<?php
$GLOBALS['THRIFT_ROOT'] = 'src/';
include 'gen-php/Hbase/Hbase_types.php';
include 'gen-php/Hbase/Hbase.php';
include 'src/transport/TSocket.php';
include 'src/transport/TBufferedTransport.php';
include 'src/protocol/TBinaryProtocol.php';
function hbase_test ()
{
$server = '192.168.222.211'; // リモートでも接続出来ます。
$port = 9090;
try {
$socket = new TSocket ($server, $port);
$transport = new TBufferedTransport ($socket);
$protocol = new TBinaryProtocol ($transport);
$client = new HbaseClient ($protocol);
$transport->open ();
$tables = $client->getTableNames ();
var_dump ($tables);
} catch (TException $e) {
error_log ('TException');
error_log ($e);
} catch (Exception $e) {
error_log ('Exception');
error_log ($e);
}
}
hbase_test ();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment