首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式碼之家 >> 編程語言 >  >> C語言 >> C++ >> 關於C++

HBase Thrift 接口 C++ 客戶端封裝實現

     編輯:關於C++

本項目封裝 HBase Thrift 接口,屏蔽底層細節,提供便捷的 C++ 客戶端操作,並進行了讀寫效能測試。基於 HBase 0.92.x Thrift 接口開發。

環境準備

1. 安裝 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-devel
cd thrift-0.8.0
./configure && make && sudo make install

2. 獲取 HBase Thrift 定義文件

wget https://www.fayea.com/apache-mirror/hbase/hbase-0.92.1/hbase-0.92.1.tar.gz
tar zxvf hbase-0.92.1.tar.gz
# 使用 Hbase.thrift 生成客戶端代碼

已封裝的核心接口

class HbCli {
public:
    // 構造/析構
    HbCli(const char* server, const char* port);
    ~HbCli();

    // 連接管理
    bool connect();
    bool disconnect();
    bool reconnect();
    inline bool isconnect();

    // DDL 操作
    bool createTable(const std::string table, const ColVec& columns);
    bool deleteTable(const std::string table);
    bool tableExists(const std::string table);

    // DML 操作
    // ...
};

使用說明

  • 支援表的增刪改查、數據讀寫
  • 連接池管理、自動重連機制
  • 後續計劃支援 HBase 0.94+ Thrift2 接口

項目適合需要從 C++ 應用高效訪問 HBase 集群的場景。

  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式碼之家 All Rights Reserved