[ 
https://issues.apache.org/jira/browse/HADOOP-2546?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12557052#action_12557052
 ] 

Michael Bieniosek commented on HADOOP-2546:
-------------------------------------------

Hi Billy,

It might be easier for you to use php's built-in http client, rather than 
writing the http client yourself.  That way, you won't have to deal with 
chunked-encoding, keepalives, etc. (which you ignore, but you might get some 
performance improvements from them). 

To do the cell fetching, for example, you could just do:

{code}
    $xml = simplexml_load_file("http://$host:60050/api/$table/row/$row";);

    $content = array();

    foreach ($xml->column as $column) {
        $content[base64_decode($column->name)] = base64_decode($column->value);
    }

    return $content;
{code}

> PHP class for Rest Interface
> ----------------------------
>
>                 Key: HADOOP-2546
>                 URL: https://issues.apache.org/jira/browse/HADOOP-2546
>             Project: Hadoop
>          Issue Type: New Feature
>          Components: contrib/hbase
>            Reporter: Billy Pearson
>            Priority: Trivial
>         Attachments: hbase_rest.php
>
>
> This is a php class to interact with the rest interface this is my first copy 
> so there could be bugs and changes to come as the rest interface changes. I 
> will make this in to a patch once I am done with it. there is lots of 
> comments in the file and notes on usage but here is some basic stuff to get 
> you started. you are welcome to suggest changes to make it faster or more 
> usable.
> Basic Usage here more details in notes with each function
>       // open a new connection to rest server. Hbase Master default port is 
> 60010
>       $hbase = new hbase_rest($ip, $port);
>       // get list of tables
>       $tables = $hbase->list_tables();
>       // get table column family names and compression stuff
>       $table_info = $hbase->table_schema("search_index");
>       // get start and end row keys of each region
>       $regions = $hbase->regions($table);
>       
>       // select data from hbase
>       $results = $hbase->select($table,$row_key);     
>       // insert data into hbase the $column and $data can be arrays with more 
> then one column inserted in one request
>       $hbase->insert($table,$row,$column(s),$data(s));
>       // delete a column from a row. Can not use * at this point to remove 
> all I thank there is plans to add this.
>       $hbase->remove($table,$row,$column);
>       
>       // start a scanner on a set range of table
>       $handle = $hbase->scanner_start($table,$cols,$start_row,$end_row);
>       // pull the next row of data for a scanner handle
>       $results = $hbase->scanner_get($handle);
>       
>       // delete a scanner handle
>       $hbase->scanner_delete($handle);
>       Example of using a scanner this will loop each row until it out of rows.
>       include(hbase_rest.php);
>       $hbase = new hbase_rest($ip, $port);
>       $handle = $hbase->scanner_start($table,$cols,$start_row,$end_row);
>       $results = true;
>       while ($results){
>               $results = $hbase->scanner_get($handle);
>               if ($results){
>                       foreach($results['column'] as $key => $value){
>                               
>                               ....
>                               code here to work with the $key/column name and 
> the $value of the column
>                               ....
>                               
>                       } // end foreach
>               } // end if
>       }// end while
>       $hbase->scanner_delete($handle);

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to