Skip to content

Repository files navigation

OBKV HBase Client

OBKV HBase Client is Java Library that can be used to access data from OceanBase by HBase-0.94 API.

Quick start

Create table in the OceanBase database:

CREATE TABLE `test1$family1` (
`K` varbinary(1024) NOT NULL,
`Q` varbinary(256) NOT NULL,
`T`bigint(20) NOT NULL,
`V` varbinary(1024) DEFAULT NULL,
PRIMARY KEY (`K`, `Q`, `T`)
);

Note:

  • test1: HBase table name;
  • family1: HBase column family name.

Import the dependency for your maven project:

<dependency>
<groupId>com.oceanbase</groupId>
<artifactId>obkv-hbase-client</artifactId>
<version>0.1.5</version>
</dependency>

Note:

  • This example version is not kept up-to-date. So check the releases page for the latest version frequently.

The code demo:

importcom.alipay.oceanbase.hbase.OHTableClient;
importorg.apache.hadoop.conf.Configuration;
importorg.apache.hadoop.hbase.client.Get;
importorg.apache.hadoop.hbase.client.Put;
importorg.apache.hadoop.hbase.client.Result;
importstaticcom.alipay.oceanbase.hbase.constants.OHConstants.*;
importstaticorg.apache.hadoop.hbase.util.Bytes.toBytes;
publicclasssimpleTest {
publicstaticvoidmain(String[] args) throwsException {
// 1. initial client for table test1Configurationconf = newConfiguration();
conf.set(HBASE_OCEANBASE_PARAM_URL, "PARAM_URL");
conf.set(HBASE_OCEANBASE_FULL_USER_NAME, "FULL_USER_NAME");
conf.set(HBASE_OCEANBASE_PASSWORD, "PASSWORD");
conf.set(HBASE_OCEANBASE_SYS_USER_NAME, "SYS_USER_NAME");
conf.set(HBASE_OCEANBASE_SYS_PASSWORD, "SYS_PASSWORD");
OHTableClienthTable = newOHTableClient("test1", conf);
hTable.init();
// 2. put data like hbasebyte[] family = toBytes("family1");
byte[] rowKey = toBytes("rowKey1");
byte[] column = toBytes("column1");
Putput = newPut(rowKey);
put.add(family, column, System.currentTimeMillis(), toBytes("value1"));
hTable.put(put);
// 3. get data like hbaseGetget = newGet(rowKey);
get.addColumn(family, column);
Resultr = hTable.get(get);
System.out.printf("column1: " + r.getColumn(family, column));
}
}

NOTE:

  • param_url is generated by ConfigServer
  • More example [TODO]
  • full_user_name: the user for accessing obkv, which format is user_name@tenant_name#cluster_name
  • sys_user_name: root@sys or proxy@sys, which have privileges to access routing system view

Documentation

  • English [Coming soon]
  • Simplified Chinese (简体中文) [Coming soon]

Licencing

OBKV HBase Client is under MulanPSL - 2.0 licence. You can freely copy and use the source code. When you modify or distribute the source code, please obey the MulanPSL - 2.0 licence.

Contributing

Contributions are warmly welcomed and greatly appreciated. Here are a few ways you can contribute:

Support

In case you have any problems when using OceanBase Database, welcome reach out for help:

About

OBKV HBase Client is Java Library that can be used to access data from OceanBase by HBase-0.94 API.

Resources

Code of conduct

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages