我正在进行一个使用hbase的项目,这个项目是基于java的。我需要知道什么是最好的java hbase客户端API。
我正在进行一个使用hbase的项目,这个项目是基于java的。我需要知道什么是最好的java hbase客户端API。
HBase在其核心库中拥有自己的Java客户端,几乎涵盖了所有功能(包括连接)。如果你需要一个异步客户端,可以尝试从stumbleupon获取asyncbase,它是一个可靠的客户端。但它的过滤器支持有限(虽然它有基本的过滤器,而且它们效果很棒)。如果你正在使用Java,我不建议通过REST使用。
Kundera是一个值得推荐的客户端,作者为此付出了很多努力。
HBaseExecutor是HBase Java客户端的简单包装器。与原生的HBase Java驱动程序相比,HBaseExecutor具有以下功能:
这里是一个使用HBaseExecutor的简单示例
Account account = createAccount();
// Insert is supported by Model/entity
hbaseExecutor.put("account", toAnyPut(account));
// Get is supported by Model/entity
Account dbAccount = hbaseExecutor.get(Account.class, "account", AnyGet.valueOf(account.getId()));
N.println(dbAccount);
// Delete the inserted account
hbaseExecutor.delete("account", AnyDelete.valueOf(account.getId()));
Account account = createAccount();
// Insert an account into HBase store
Put put = new Put(Bytes.toBytes(account.getId()));
put.addColumn(Bytes.toBytes("name"), Bytes.toBytes("firstName"), Bytes.toBytes(account.getName().firstName().value()));
put.addColumn(Bytes.toBytes("name"), Bytes.toBytes("lastName"), Bytes.toBytes(account.getName().lastName().value()));
put.addColumn(Bytes.toBytes("contact"), Bytes.toBytes("city"), Bytes.toBytes(account.getContact().city().value()));
put.addColumn(Bytes.toBytes("contact"), Bytes.toBytes("state"), Bytes.toBytes(account.getContact().state().value()));
put.addColumn(Bytes.toBytes("createTime"), Bytes.toBytes(""), Bytes.toBytes(N.stringOf(account.createTime().value())));
hbaseExecutor.put("account", put);
// Get the inserted account from HBase store
Result result = hbaseExecutor.get("account", new Get(Bytes.toBytes(account.getId())));
CellScanner cellScanner = result.cellScanner();
while (cellScanner.advance()) {
final Cell cell = cellScanner.current();
N.println(Bytes.toString(cell.getFamilyArray(), cell.getFamilyOffset(), cell.getFamilyLength()));
N.println(Bytes.toString(cell.getQualifierArray(), cell.getQualifierOffset(), cell.getQualifierLength()));
N.println(Bytes.toString(cell.getValueArray(), cell.getValueOffset(), cell.getValueLength()));
// ... a lot of work to do
}
// Delete the inserted account from HBase store.
hbaseExecutor.delete("account", new Delete(Bytes.toBytes(account.getId())));
(声明:我是HBaseExecutor的开发人员)
playOrm是另一个Java工具,您可以在实体上注释并立即运行。它故意不符合JPA标准,因为nosql与传统关系型数据库有很大的不同。它具有像findAll()这样的方法,因为您希望在nosql中并行读取。
playOrm确实添加了JQL,但对于nosql来说有所不同...例如,您可以将万亿行分成10亿个分区,并在任何分区中进行JQL查询并与其他表连接。如果您来自JPA世界,它会使向noSql的过渡更加容易。