Copyright © 2016 Huawei Technologies Co., Ltd. All rights reserved. Page 11
HBase
HBase的表设计工具 、连
接池管理和增强的SDK,来
简化复杂数据表的业务开发
try {
table = new HTable(conf, TABLE);
// 1. Generate RowKey.
{......}
// 2. Create Put instance.
Put put = new Put(rowKey);
// 3. Convert columns into qualifiers(Need to consider
merging cold columns).
// 3.1. Add hot columns.
{.......}
// 3.2. Merge cold columns.
{.......}
put.add(COLUMN_FAMILY, Bytes.toBytes("QA"), hotCol);
// 3.3. Add cold columns.
put.add(COLUMN_FAMILY, Bytes.toBytes("QB"),
coldCols);
// 4. Put into HBase.
table.put(put);
} catch (IOException e) {
// Handle IOE. Need to re-create connections under
some scenarios.
}
try {
table = new ClusterTable(conf,
CLUSTER_TABLE);
// 1. Create CTRow instance.
CTRow row = new CTRow();
// 2. Add columns.
{........}
// 3. Put into HBase.
table.put(TABLE, row);
} catch (IOException e) {
// Does not care connection re-creation.
}
HBase
原生
API
增强
API
Recoverable
Connection
Manager
Schema
Data
Enhance Hbase SDK
Hbase
Design
Tools
HBase API
易开发