What is HBase Client API?

Apache HBase provides Java APIs to perform CURD operations. HBase is designed in Java. It has native APIs, using that it provides programmatic access to Data Manipulation Language (DML).


Class HBase Configuration

This class is used to add HBase configuration files to a Configuration and it belongs to org.apache.hadoop.hbase package.

Let us see its methods and description.

Methods Description
static org.apache.hadoop.conf.Configuration create() This method is used to create Configuration with HBase resources.

Class HTable

HTable belongs to an internal class that represents the HBase table. It is an implementation of a class that is used to communicate with a single table. It belongs to org.apache.hadoop.hbase.client class.

Let us see its constructors and description.

Constructor Description
HTable() Example- HTable(TableName tableName, ClusterConnection connection, ExecutorService pool) By using this constructor, we can create an object to access an HBase table.

Let us see its methods and description.

Methods Description
void close() This method is used to release all the resources of the HTable.
void delete(Delete delete) This method is used to delete the specified cells/row.
boolean exists(Get get) By using this method, you can test the existence of columns in the table, as specified by Get.
Result get(Get get) This method is used to retrieve certain cells from a given row.
org.apache.hadoop.conf.Configuration getConfiguration() This method is used to return the configuration object used by this instance.
TableName getName() This method is used to return the table name instance of this table.
HTableDescriptor getTableDescriptor() This method is used to return the table descriptor for this table.
byte[] getTableName() This method is used to return the name of this table.
void put(Put put) By using this method, you can insert data into the table.


Class Put

This class performs Put operations on a single row and belongs to org.apache.hadoop.hbase.client package.

Let us see its constructors and description.

Constructor Description
Put(byte[] row) By using this constructor, we can create a Put operation for the specified row.
Put(byte[] rowArray, int rowOffset, int rowLength) By using this constructor, we can make a copy of the passed-in row key to keep local.
Put(byte[] rowArray, int rowOffset, int rowLength, long ts) By using this constructor, we can make a copy of the passed-in row key to keep local.
Put(byte[] row, long ts) By using this constructor, we can create a Put operation for the specified row, using a given timestamp.

Let us see its methods and description.

Methods Description
Put add(byte[] family, byte[] qualifier, byte[] value) This method is used to add the specified column and value to this Put operation.
Put add(byte[] family, byte[] qualifier, long ts, byte[] value) This method is used to add the specified column and value, with the specified timestamp as its version to this Put operation.
Put add(byte[] family, ByteBuffer qualifier, long ts, ByteBuffer value) This method is used to add the specified column and value, with the specified timestamp as its version to this Put operation.
Put add(byte[] family, ByteBuffer qualifier, long ts, ByteBuffer value) This method is used to add the specified column and value, with the specified timestamp as its version to this Put operation.


Class Get

This class performs Get operations on a single row and belongs to org.apache.hadoop.hbase.client package.

Let us see its constructor and description.

Constructor Description
Get(byte[] row) By using this constructor, we can create a Get operation for the specified row.

Let us see its methods and description.

Methods Description
Get addColumn(byte[] family, byte[] qualifier) This method is used to retrieve the column from the specific family with the specified qualifier.
Get addFamily(byte[] family) This method is used to retrieve all columns from the specified family.


Class Delete

This class performs delete operation on a single row and belongs to org.apache.hadoop.hbase.client package. To perform delete on the entire row instantiate a Delete object with the row to delete.

Let us see its constructor and description.

Constructor Description
Delete(byte[] row) This constructor is used to create a Delete operation for the specified row.
Delete(byte[] rowArray, int rowOffset, int rowLength) This constructor is used to create a Delete operation for the specified row and timestamp.
Delete(byte[] rowArray, int rowOffset, int rowLength, long ts) This constructor is used to create a Delete operation for the specified row and timestamp.
Delete(byte[] row, long timestamp) This constructor is used to create a Delete operation for the specified row and timestamp.

Let us see its methods and description.

Methods Description
Delete addColumn(byte[] family, byte[] qualifier) This method is used to delete the latest version of the specified column.
Delete addColumns(byte[] family, byte[] qualifier, long timestamp) This method is used to delete all versions of the specified column with a timestamp less than or equal to the specified timestamp.
Delete addFamily(byte[] family) This method is used to delete all versions of all columns of the specified family.
Delete addFamily(byte[] family, long timestamp) This method is used to delete all columns of the specified family with a timestamp less than or equal to the specified timestamp.


Class Result

This class is used to send single row results of a Get or a Scan query.

Let us see its constructor and description.

Constructor Description
Result() By using this constructor, we can create an empty Result with no KeyValue payload; returns null if you call raw Cells().

Let us see its methods and description.

Methods Description
byte[] getValue(byte[] family, byte[] qualifier) Using this method we can see the latest version of a column.
byte[] getRow() This method will fetch the row key.