开发者

what is best HBase client API for java [closed]

Closed. This question is seeking recommendations for books, tools开发者_如何学运维, software libraries, and more. It does not meet Stack Overflow guidelines. It is not currently accepting answers.

We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.

Closed 4 years ago.

Improve this question

Im working on a project in which i got to use hbase.The project is in java based. I need to know what is the best hbase client api for java.


HBase has its own java client in core library. It covers pretty much everything. (Got connection as well). If you need a asynchronous client You can check asyncbase from stumbleupon, which is a solid client. But it's filter support is limited.(it has basic filters though, and they work like charm). If you are using java I wouldn't recommend using via rest.


Kundera is a recommend client for use. the author is work hard for it.


Kundera is a object-datastore mapping tool for Hbase alongwith Cassandra and MongoDB.

Some of the salient features are:

  • JPA 2.0 compliant.
  • Column/ column family indexing using lucene.
  • Support for entity relationships and JPA queries.
  • Cross-datastore persistence

It's hosted here: https://github.com/impetus-opensource/Kundera


playOrm is a another java tool where you can annotate your entities and immediately be up and running. It is NOT JPA compliant on purpose as nosql is too different. It has methods like findAll() as you want to parallel your reads in nosql.

playOrm does add JQL but with a twist for nosql....As an example of the twist, you can partition a trillion row into 1 billion partitions and do JQL into any partition and join with other tables. It makes a transition to noSql much easier if you come from the JPA world.


HBaseExecutor, a simple wrapper of HBase Java client. Comparing to the native HBase Java Driver, HBaseExecutor has below features:

  • Provides consistent/Integrated/Concise APIs for operations(CRUD) with entity/String.
  • Wrappers for the bytes parameters/operations to improve operability.

Here is a simple sample with 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()));

Comparing to the sample with HBase Java client:

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())));

(Declaration:I'm the developer of HBaseExecutor)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜