API compatibility
The OBKV-HBase client uses the functionality provided by the HTableInterface within the HBase system. The API compatibility is detailed as follows.
| Modifier and type | Method and description | Compatibility |
|---|---|---|
| Result | append (Append append) Appends values to one or more columns within a single row. | Supported |
| Object[] | batch(List<? extends Row> actions) Same as batch(List, Object[]), but returns an array of results instead of using a results parameter reference. |
Not supported |
| void | batch(List<? extends Row> actions, Object[] results) Method that does a batch call on Deletes, Gets, Puts, Increments, Appends and RowMutations. | Not supported |
| boolean | checkAndDelete (byte[] row, byte[] family, byte[] qualifier, byte[] value,Delete delete) Atomically checks if a row/family/qualifier value matches the expected value. |
Supported |
| boolean | checkAndPut (byte[] row, byte[] family, byte[] qualifier, byte[] value, Put put) Atomically checks if a row/family/qualifier value matches the expected value. |
Supported |
| void | close() Releases any resources help or pending changes in internal buffers. | Supported |
| <T extends CoprocessorProtocol,R>Map<byte[],R> | coprocessorExec(Class |
Not supported |
| <T extends CoprocessorProtocol,R> void | coprocessorExec(Class |
Not supported |
| <T extends CoprocessorProtocol > T | coprocessorProxy(Class |
Not supported |
| void | delete(Delete delete) Deletes the specified cells/row. | Supported |
| void | delete(List<Delete> deletes) Deletes the specified cells/rows in bulk. | Supported |
| boolean | exists(Get get) Test for the existence of columns in the table, as specified in the Get. | Supported |
| void | flushCommits() Executes all the buffered Put operations. | Supported |
| Result | get(Get get) Extracts certain cells from a given row. | Supported |
| Result[] | get(List<Get> gets) Extracts certain cells from the given rows, in batch. | Supported |
| org.apache.hadoop.conf.Configuration | getConfiguration() Returns the Returns the Configuration object used by this instance. | Supported |
| Result | getRowOrBefore(byte[] row, byte[] family) Deprecated. As of version 0.92 this method is deprecated without replacement. getRowOrBefore is used internally to find entries in .META. and makes various assumptions about the table (which are true for .META. but not in general) to be efficient. | Deprecated |
| ResultScanner | getScanner(byte[] family) Gets a scanner on the current table for the given family. | Supported |
| ResultScanner | getScanner(byte[] family, byte[] qualifier) Gets a scanner on the current table for the given family and qualifier. | Supported |
| ResultScanner | getScanner(Scan scan) Returns a scanner on the current table as specified by the Scan object. | Supported |
| HTableDescriptor | getTableDescriptor() Gets the table descriptor for this table. | Not supported |
| byte[] | getTableName() Gets the name of this table. | Supported |
| long | getWriteBufferSize() Returns the maximum size in bytes of the write buffer for this HTable. | Supported |
| Result | increment(Increment increment) Increments one or more columns within a single row. | Supported |
| long | incrementColumnValue(byte[] row, byte[] family, byte[] qualifier, long amount) Atomically increments a column value. | Supported |
| long | incrementColumnValue(byte[] row, byte[] family, byte[] qualifier, long amount, Durability durability) Atomically increments a column value. | Supported |
| boolean | isAutoFlush() Tells whether or not 'auto-flush' is turned on. | Supported |
| RowLock | lockRow(byte[] row) RowLock and associated operations are deprecated | Deprecated |
| void | mutateRow(RowMutations rm) Performs multiple mutations atomically on a single row. | Not supported |
| void | put(List<Put> puts) Puts some data in the table, in batch. | Supported |
| void | put(Put put) Puts some data in the table. | Supported |
| void | setAutoFlush(boolean autoFlush) See setAutoFlush(boolean, boolean) | Supported |
| void | setAutoFlush(boolean autoFlush, boolean clearBufferOnFail) Turns 'auto-flush' on or off. | Supported |
| void | setWriteBufferSize(long writeBufferSize) Sets the size of the buffer in bytes. | Supported |
| void | unlockRow(RowLock rl) RowLock and associated operations are deprecated | Deprecated |
Differences in API usage
Due to architectural differences, some configuration code needs to be adjusted when migrating code from open-source HBase to OBKV-HBase.
The data access code for open-source HBase and OBKV-HBase remains unchanged, ensuring compatibility in the data access part. The main differences lie in:
- Configuration: The architecture and configuration settings differ between open-source HBase and OBKV-HBase.
- OHTableClient: Data access requires using the handle based on OBKV-HBase.
Below are some examples:
Open-source HBase code:
public class HBaseInsertDemo {
public static void main(String[] args) throws Exception {
// Configure HBase
Configuration conf = HBaseConfiguration.create();
conf.set("hbase.zookeeper.quorum", "your_zookeeper_quorum"); // Set ZooKeeper address
conf.set("hbase.zookeeper.property.clientPort", "2181"); // Set ZooKeeper port
// Obtain The table handle
TableName tableName = TableName.valueOf("your_table_name");
HTable table =new HTable(tableName, conf);
// Prepare to insert data
Put put = new Put(Bytes.toBytes("row_key"));
put.addColumn(Bytes.toBytes("cf"), Bytes.toBytes("qualifier"), Bytes.toBytes("value")); // Column family, column qualifier, value
table.put(put);
// Close resources
table.close();
System.out.println("Data inserted successfully!");
}
}
OBKV-HBase code:
public class OBHBaseInsertDemo {
public static void main(String[] args) throws Exception {
// Configure HBase
Configuration conf = new Configuration();
conf.set(HBASE_OCEANBASE_FULL_USER_NAME, "");
conf.set(HBASE_OCEANBASE_PASSWORD, "");
conf.set(HBASE_OCEANBASE_PARAM_URL, "");
conf.set(HBASE_OCEANBASE_SYS_USER_NAME, "");
conf.set(HBASE_OCEANBASE_SYS_PASSWORD, "");
// Obtain the table handle
TableName tableName = TableName.valueOf("your_table_name");
OHTableClient table = new OHTableClient(tableName, conf); // Create htable object
// Prepare to insert data
Put put = new Put(Bytes.toBytes("row_key"));
put.addColumn(Bytes.toBytes("cf"), Bytes.toBytes("qualifier"), Bytes.toBytes("value")); // Column family, column qualifier, value
table.put(put);
// Close resources
table.close();
System.out.println("Data inserted successfully!");
}
}