Ejemplo n.º 1
0
use Hbase\Mutation;
use Hbase\TScan;
$socket = new TSocket('localhost', 9090);
$socket->setSendTimeout(10000);
// Ten seconds (too long for production, but this is just a demo ;)
$socket->setRecvTimeout(20000);
// Twenty seconds
$transport = new TBufferedTransport($socket);
$protocol = new TBinaryProtocol($transport);
$client = new HbaseClient($protocol);
try {
    $transport->open();
    $table = 'note';
    $filter = "QualifierFilter(>=, 'binary:1500')";
    // greater than 1500
    $scan = new TScan(array('startRow' => 'rowkey-1', 'stopRow' => 'rowkey-2', 'filterString' => $filter, 'sortColumns' => true));
    $scanid = $client->scannerOpenWithScan($table, $scan, null);
    $rowresult = $client->scannerGet($scanid);
    // print_r($rowresult);
    echo "\nrow: {$rowresult[0]->row}, cols: \n\n";
    // 위에 TScan에 sortColumns 옵션을 안주면 $rowresult[0]->columns 로 접근.
    $values = $rowresult[0]->sortedColumns;
    // asort($values);
    foreach ($values as $k => $v) {
        echo "  {$k} => {$v->value}\n";
    }
    $client->scannerClose($scanid);
    $transport->close();
} catch (TException $e) {
    print 'TException: ' . $e->__toString() . ' Error: ' . $e->getMessage() . "\n";
}
Ejemplo n.º 2
0
  public function scannerOpen($tableName, $startRow, $columns, $attributes);
  public function scannerOpenWithStop($tableName, $startRow, $stopRow, $columns, $attributes);
  public function scannerOpenWithPrefix($tableName, $startAndPrefix, $columns, $attributes);
  public function scannerOpenTs($tableName, $startRow, $columns, $timestamp, $attributes);
  public function scannerOpenWithStopTs($tableName, $startRow, $stopRow, $columns, $timestamp, $attributes);
  public function scannerGet($id);
  public function scannerGetList($id, $nbRows);
  public function scannerClose($id);
*/
echo "----scanner get ------\r\n";
$startRow = '1';
$columns = array('column' => 'score');
//
$scan = $client->scannerOpen($tableName, $startRow, $columns, $attributes);
//$startAndPrefix = '13686667';
//$scan = $client->scannerOpenWithPrefix($tableName,$startAndPrefix,$columns,$attributes);
//$startRow = '1';
//$stopRow = '2';
//$scan = $client->scannerOpenWithStop($tableName, $startRow, $stopRow, $columns, $attributes);
//$arr = $client->scannerGet($scan);
$nbRows = 1000;
$arr = $client->scannerGetList($scan, $nbRows);
var_dump('count of result :' . count($arr));
foreach ($arr as $k => $TRowResult) {
    // code...
    //var_dump($TRowResult);
}
$client->scannerClose($scan);
//close transport
$transport->close();