Пример #1
0
foreach ($descriptors as $col) {
    echo "  column: {$col->name}, maxVer: {$col->maxVersions}\n";
}
$t = "table1";
echo "column families in {$t}:\n";
$descriptors = $client->getColumnDescriptors($t);
asort($descriptors);
foreach ($descriptors as $col) {
    echo "  column: {$col->name}, maxVer: {$col->maxVersions}\n";
}
$t = "table1";
$row = "row_name";
$valid = "foobar-生ビ";
$mutations = array(new Mutation(array('column' => 'entry:foo', 'value' => $valid)));
// 多记录批量提交(200提交一次时测试小记录大概在5000/s左右):  $rows = array('timestamp'=>$timestamp, 'columns'=>array('txt:col1'=>$col1, 'txt:col2'=>$col2, 'txt:col3'=>$col3));  $records = array(rowkey=>$rows,...);  $batchrecord = array();  foreach ($records as $rowkey => $rows) {      $timestamp = $rows['timestamp'];      $columns = $rows['columns'];      // 生成一条记录      $record = array();      foreach($columns as $column => $value) {          $col = new Mutation(array('column'=>$column, 'value'=>$value));          array_push($record, $col);      }      // 加入记录数组      $batchTmp = new BatchMutation(array('row'=>$rowkey, 'mutations'=>$record));      array_push($batchrecord, $batchTmp);  }  $ret = $hbase->mutateRows('test', $batchrecord);
$client->mutateRow($t, $row, $mutations, null);
$table_name = "table1";
$row_name = 'row_name';
$fam_col_name = 'entry:foo';
$arr = $client->get($table_name, $row_name, $fam_col_name, null);
// $arr = array
foreach ($arr as $k => $v) {
    // $k = TCell
    echo "value = {$v->value} , <br>  ";
    echo "timestamp = {$v->timestamp}  <br>";
}
$table_name = "table1";
$row_name = "row_name";
$arr = $client->getRow($table_name, $row_name, null);
// $client->getRow return a array
foreach ($arr as $k => $TRowResult) {
Пример #2
0
asort($descriptors);
foreach ($descriptors as $col) {
    var_dump("  column: {$col->name}, maxVer: {$col->maxVersions}\n");
}
//set clomn
//add update column data
$time = time();
var_dump($time);
$row = '2';
$valid = "foobar-" . $time;
$mutations = array(new \Hbase\Mutation(array('column' => 'score', 'value' => $valid)));
$mutations1 = array(new \Hbase\Mutation(array('column' => 'score:a', 'value' => $time)));
$attributes = array();
//add row, write a row
$row1 = $time;
$client->mutateRow($tableName, $row1, $mutations1, $attributes);
echo "-------write row {$row1} ---\r\n";
//update row
$client->mutateRow($tableName, $row, $mutations, $attributes);
//get column data
$row_name = $time;
$fam_col_name = 'score:a';
$arr = $client->get($tableName, $row_name, $fam_col_name, $attributes);
// $arr = array
foreach ($arr as $k => $v) {
    // $k = TCell
    echo " ------ get one : value = {$v->value} , <br>  ";
    echo " ------ get one : timestamp = {$v->timestamp}  <br>";
}
echo "----------\r\n";
$arr = $client->getRow($tableName, $row_name, $attributes);