phphbasethriftstargate

insert data to hbase


I am trying to insert the data to hbase table wth one cloumn family info with column keys name,age..

in table hbase format should be like this

row         column+cell
1           column=info:name timestamp=--- value=vani
2           column=info name timestamp=--- value=veena

.. the above this be the format.. then I am using THrift API with hbase +php..

Now I have to write php code for above data insertion to hbase table

plz can anyone tel me.. how to do?


Solution

  • You can use something like this:

    // get HbaseClient
    $client = <your code>;
    
    $mutation =new Mutation(array("column" => "info:name", "value" => "vani"));
    $client->mutateRow("table_name", $row_key = 1, array($mutation));
    
    $mutation =new Mutation(array("column" => "info:name", "value" => "veena"));
    $client->mutateRow("table_name", $row_key = 2, array($mutation));
    

    You need to get client before using mutations, because client includes files needed for mutations and many other;

    You can also mutate multiple rows at one time using $client->mutateRows() function and batch mutations

    http://hbase.apache.org/apidocs/org/apache/hadoop/hbase/thrift/doc-files/Hbase.html