HBase – Client API

  • Post author:
  • Post category:HBase
  • Post comments:5 Comments
client API

This chapter describes the java client API for HBase that is used to perform CRUD operations on HBase tables. HBase is written in Java and has a Java Native API. Therefore it provides programmatic access to Data Manipulation Language (DML).

Class HBase Configuration

Adds HBase configuration files to a Configuration. This class belongs to the org.apache.hadoop.hbase package.

Methods and description

S.No.Methods and Description
1static org.apache.hadoop.conf.Configuration create()This method creates a Configuration with HBase resources.

Class HTable

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

Constructors

S.No.Constructors and Description
1HTable()
2HTable(TableName tableName, ClusterConnection connection, ExecutorService pool)Using this constructor, you can create an object to access an HBase table.

Methods and description

S.No.Methods and Description
1void close()Releases all the resources of the HTable.
2void delete(Delete delete)Deletes the specified cells/row.
3boolean exists(Get get)Using this method, you can test the existence of columns in the table, as specified by Get.
4Result get(Get get)Retrieves certain cells from a given row.
5org.apache.hadoop.conf.Configuration getConfiguration()Returns the Configuration object used by this instance.
6TableName getName()Returns the table name instance of this table.
7HTableDescriptor getTableDescriptor()Returns the table descriptor for this table.
8byte[] getTableName()Returns the name of this table.
9void put(Put put)Using this method, you can insert data into the table.

Class Put

This class is used to perform Put operations for a single row. It belongs to the org.apache.hadoop.hbase.client package.

Constructors

S.No.Constructors and Description
1Put(byte[] row)Using this constructor, you can create a Put operation for the specified row.
2Put(byte[] rowArray, int rowOffset, int rowLength)Using this constructor, you can make a copy of the passed-in row key to keep local.
3Put(byte[] rowArray, int rowOffset, int rowLength, long ts)Using this constructor, you can make a copy of the passed-in row key to keep local.
4Put(byte[] row, long ts)Using this constructor, we can create a Put operation for the specified row, using a given timestamp.

Methods

S.No.Methods and Description
1Put add(byte[] family, byte[] qualifier, byte[] value)Adds the specified column and value to this Put operation.
2Put add(byte[] family, byte[] qualifier, long ts, byte[] value)Adds the specified column and value, with the specified timestamp as its version to this Put operation.
3Put add(byte[] family, ByteBuffer qualifier, long ts, ByteBuffer value)Adds the specified column and value, with the specified timestamp as its version to this Put operation.
4Put add(byte[] family, ByteBuffer qualifier, long ts, ByteBuffer value)Adds the specified column and value, with the specified timestamp as its version to this Put operation.

Class Get

This class is used to perform Get operations on a single row. This class belongs to the org.apache.hadoop.hbase.client package.

Constructor

S.No.Constructor and Description
1Get(byte[] row)Using this constructor, you can create a Get operation for the specified row.
2Get(Get get)

Methods

S.No.Methods and Description
1Get addColumn(byte[] family, byte[] qualifier)Retrieves the column from the specific family with the specified qualifier.
2Get addFamily(byte[] family)Retrieves all columns from the specified family.

Class Delete

This class is used to perform Delete operations on a single row. To delete an entire row, instantiate a Delete object with the row to delete. This class belongs to the org.apache.hadoop.hbase.client package.

Constructor

S.No.Constructor and Description
1Delete(byte[] row)Creates a Delete operation for the specified row.
2Delete(byte[] rowArray, int rowOffset, int rowLength)Creates a Delete operation for the specified row and timestamp.
3Delete(byte[] rowArray, int rowOffset, int rowLength, long ts)Creates a Delete operation for the specified row and timestamp.
4Delete(byte[] row, long timestamp)Creates a Delete operation for the specified row and timestamp.

Methods

S.No.Methods and Description
1Delete addColumn(byte[] family, byte[] qualifier)Deletes the latest version of the specified column.
2Delete addColumns(byte[] family, byte[] qualifier, long timestamp)Deletes all versions of the specified column with a timestamp less than or equal to the specified timestamp.
3Delete addFamily(byte[] family)Deletes all versions of all columns of the specified family.
4Delete addFamily(byte[] family, long timestamp)Deletes all columns of the specified family with a timestamp less than or equal to the specified timestamp.

Class Result

This class is used to get a single row result of a Get or a Scan query.

Constructors

S.No.Constructors
1Result()Using this constructor, you can create an empty Result with no KeyValue payload; returns null if you call raw Cells().

Methods

S.No.Methods and Description
1byte[] getValue(byte[] family, byte[] qualifier)This method is used to get the latest version of the specified column.
2byte[] getRow()This method is used to retrieve the row key that corresponds to the row from which this Result was created.

This Post Has 5 Comments

Leave a Reply