The hbase-Thrift project encapsulates the hbase thrift interface and shields the underlying details so that you can easily access the hbase cluster through the hbase thrift interface, at the same time, the Read and Write efficiency of the C ++ client is tested. This project is currently based on the hbase thrift interface. As for the hbase thrift interface in hbase 0.94, further support will be considered later.
Prerequisites
1) download, decompress, and install thrift-0.8.0.
Wget Https: // Dist.apache.org/repos/dist/release/thrift/0.8.0/thrift-0.8.0.tar.gz Tar Zxvf thrift- 0.8 . 0 . Tar . GZ Sudo Yum Install Automake libtool flex bison pkgconfig Gcc -C ++ boost-devel libevent-devel zlib-devel Python-devel ruby- Develcd Thrift - 0.8 . 0 . / Configure Make Sudo Make Install
2) download, unzip the hbase-0.92.1 or previous version, the user generates the client thrift interface according to hbase. Thrift FileCode.
WgetHTTP://Www.fayea.com/apache-#/hbase/hbase-0.92.1/hbase-0.92.1.tar.gzTarZxvf hbase-0.92.1.Tar. GZ
Interface implementation
The following interfaces are encapsulated:
Class Hbcli { Public : // Constructor and destructor Hbcli ( Const Char * Server,Const Char * Port ); ~ Hbcli (); // Util Functions Bool Connect (); Bool Disconnect (); Bool Reconnect (); inline Bool Isconnect (); // Hbase DDL Functions Bool Createtable ( Const STD :: String Table, Const Colvec & Columns ); Bool Deletetable ( Const STD :: String Table ); Bool Tableexists ( Const STD :: String Table ); // Hbase DML Functions Bool Putrow ( Const STD :: String Table, Const STD :: String Row, Const STD :: String Column, Const STD :: String Value ); Bool Putrowwithcolumns ( Const STD :: String Table, Const STD :: String Row, Const Strmap columns ); Bool Putrows ( Const STD :: String Table, Const Rowmap rows ); Bool Getrow ( Const STD ::String Table, Const STD :: String Row, resvec & Rowresult ); Bool Getrowwithcolumns ( Const STD :: String Table, Const STD :: String Row, Const Strvec columns, resvec & Rowresult ); Bool Getrows (Const STD :: String Table, Const Strvec rows, resvec & Rowresult ); Bool Getrowswithcolumns ( Const STD :: String Table, Const Strvec rows, Const Strvec columns, resvec & Rowresult ); Bool Delrow ( Const STD ::String Table, Const STD :: String Row ); Bool Delrowwithcolumn ( Const STD :: String Table, Const STD :: String Row, Const STD :: String Column ); Bool Delrowwithcolumns (Const STD :: String Table, Const STD :: String Row, Const Strvec columns ); Bool Scan ( Const STD :: String Table, Const STD :: String Startrow, strvec columns, resvec & Values ); Bool Scanwithstop ( Const STD :: String Table, Const STD :: String Startrow, Const STD :: String Stoprow, strvec columns, resvec & Values ); // Hbase util Functions Void Printrow ( Const Resvec & Rowresult ); Private : Boost: shared_ptr <TTransport> Socket; Boost: shared_ptr <TTransport> Transport; Boost: shared_ptr <Tprotocol> Protocol; hbaseclient client; Bool _ Is_connected ;};
Compile and install
1) run the thrift command to generate the client code of the C ++ module:
Thrift -- genCPP[Hbase-root]/src/main/resources/org/Apache/hadoop/hbase/thrift/hbase. Thrift
2) execute make to generate binaryProgram:
Make demo
Make perf
3) execute the binary program:
./Demo ./Testput ./Testget
Temporarily update these content, interested, see: https://github.com/ypf412/hbase-thrift