简单的CRUD操作,参考HBase权威指南(中文版).pdf,下面的是对HBase基本操作进行面向对象封装后的CRUD操作。所有以HBase作为存储数据库的DAO层,都继承
HBaseDaoImpl类,下列是使用示例。
新增操作
public
String add(XControl control)
throws
Exception {
String id = HBaseRowKeyUtil.getRowKey(
controlTableName
);
control.setId(id);
control.setStatus(Status.
ADD
.getValue());
PutDeletepd=HBaseConvetorUtil.convetor(control,id);
super
.savePutDelete(
controlTableName
, pd);
return
id;
更新操作
public
String update(XControl control)
throws
Exception {
String id = control.getId();
PutDelete pd=HBaseConvetorUtil.convetor(control,id);
super
.savePutDelete(
controlTableName
, pd);
return
id;
}
查询操作
public
XControl getXControl(String id)
throws
Exception {
return
super
.get(XControl.
class
,
controlTableName
, id);
}
删除操作
public
void
delete(String id)
throws
IOException {
delete(
controlTableName
, id);
}
|
转载于:https://www.cnblogs.com/CRXY/p/4569762.html