Deep dive into Java Client API for HBase and its associated classes

Last updated on May 30 2022
Sonali Singh

Table of Contents

Deep dive into Java Client API for HBase and its associated classes

HBase – Client API

This Blog describes the java client API for HBase that’s employed to perform CRUD operations on HBase tables. HBase is written in Java and has a Java Native API. Therefore it provides programmatic access to Info 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 outline

S.No. Methods and Outline
1 static 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’s employed to communicate with a single HBase table. This class belongs to the org.apache.hadoop.hbase.client class.

Constructors

S.No. Constructors and Outline
1 HTable()
2 HTable(TableName tableName, ClusterConnection connection, ExecutorService pool)

Using this constructor, you can create an object to access an HBase table.

Methods and outline

S.No. Methods and Outline
1 void close()

Releases all the resources of the HTable.

2 void delete(Delete delete)

Deletes the required cells/row.

3 boolean exists(Get get)

Using this method, you can test the existence of columns in the table, as required by Get.

4 Result get(Get get)

Retrieves certain cells from a given row.

5 org.apache.hadoop.conf.Configuration getConfiguration()

Returns the Configuration object employed by this instance.

6 TableName getName()

Returns the table name instance of this table.

7 HTableDescriptor getTableDescriptor()

Returns the table descriptor for this table.

8 byte[] getTableName()

Returns the name of this table.

9 void put(Put put)

Using this method, you can insert info into the table.

Class Put

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

Constructors

S.No. Constructors and Outline
1 Put(byte[] row)

Using this constructor, you can create a Put operation for the required row.

2 Put(byte[] rowArray, int rowOffset, int rowLength)

Using this constructor, you can make a copy of the passed-in row key to keep local.

3 Put(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.

4 Put(byte[] row, long ts)

Using this constructor, we can create a Put operation for the required row, using a given timestamp.

Methods

S.No. Methods and Outline
1 Put add(byte[] family, byte[] qualifier, byte[] value)

Adds the required column and value to this Put operation.

2 Put add(byte[] family, byte[] qualifier, long ts, byte[] value)

Adds the required column and value, with the required timestamp as its version to this Put operation.

3 Put add(byte[] family, ByteBuffer qualifier, long ts, ByteBuffer value)

Adds the required column and value, with the required timestamp as its version to this Put operation.

4 Put add(byte[] family, ByteBuffer qualifier, long ts, ByteBuffer value)

Adds the required column and value, with the required timestamp as its version to this Put operation.

Class Get

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

Constructor

S.No. Constructor and Outline
1 Get(byte[] row)

Using this constructor, you can create a Get operation for the required row.

2 Get(Get get)

Methods

S.No. Methods and Outline
1 Get addColumn(byte[] family, byte[] qualifier)

Retrieves the column from the specific family with the required qualifier.

2 Get addFamily(byte[] family)

Retrieves all columns from the required family.

Class Delete

This class is employed 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 Outline
1 Delete(byte[] row)

Creates a Delete operation for the required row.

2 Delete(byte[] rowArray, int rowOffset, int rowLength)

Creates a Delete operation for the required row and timestamp.

3 Delete(byte[] rowArray, int rowOffset, int rowLength, long ts)

Creates a Delete operation for the required row and timestamp.

4 Delete(byte[] row, long timestamp)

Creates a Delete operation for the required row and timestamp.

Methods

S.No. Methods and Outline
1 Delete addColumn(byte[] family, byte[] qualifier)

Deletes the latest version of the required column.

2 Delete addColumns(byte[] family, byte[] qualifier, long timestamp)

Deletes all versions of the required column with a timestamp less than or equal to the required timestamp.

3 Delete addFamily(byte[] family)

Deletes all versions of all columns of the required family.

4 Delete addFamily(byte[] family, long timestamp)

Deletes all columns of the required family with a timestamp less than or equal to the required timestamp.

Class Result

This class is employed to get a one row result of a Get or a Scan query.

Constructors

S.No. Constructors
1 Result()

Using this constructor, you’ll create an empty Result with no KeyValue payload; returns null if you call raw Cells().

Methods

S.No. Methods and Outline
1 byte[] getValue(byte[] family, byte[] qualifier)

This method is employed to get the latest version of the required column.

2 byte[] getRow()

This method is employed to urge the row key that corresponds to the row from which this Result was created.

 

So, this brings us to the end of blog. This Tecklearn ‘Deep dive into Java Client API for HBase and its associated classes’ helps you with commonly asked questions if you are looking out for a job in HBase and No-SQL Database Domain.

If you wish to learn HBase and build a career in HBase or No-SQL Database domain, then check out our interactive, Apache HBase Training, that comes with 24*7 support to guide you throughout your learning period. Please find the link for course details:

https://www.tecklearn.com/course/apache-hbase-training/

Apache HBase Training

About the Course

Tecklearn Apache HBase training will master the powerful NoSQL distributed database. You will learn HBase architecture, data analytics using HBase, integration with Hive, monitoring cluster using ZooKeeper and working on real-life industry projects. Build your career as a certified HBase professional through our hands-on training with real-world examples. Upon completion of this online training, you will hold a solid understanding and hands-on experience with Apache HBase.

Why Should you take Apache HBase Training?

  • HBase is now the largest data-driven service serving top websites including Facebook Messaging Platform.
  • There is Strong demand for HBase qualified professionals and they are paid big bucks for the right skills.
  • According to indeed.com, the average pay of an HBase developer stands at $81,422 per annum.

What you will Learn in this Course?

Introduction to HBase and NoSQL

  • Introduction to HBase
  • Fundamentals of HBase
  • What is NoSQL
  • NoSQL Vs RDBMS
  • Why HBase
  • Where to use HBase

HBase Data Modelling

  • Data Modelling
  • HDFS vs. HBase
  • HBase Use Cases

HBase Architecture and Components

  • HBase Architecture
  • Components of HBase Cluster

HBase Installation

  • Prerequisites for HBase Installation
  • Installation Steps

Programming in HBase

  • Create an Eclipse Project for HBase
  • Simple Table Creation from Java in HBase
  • HBase API
  • HBase Shell
  • Primary operations and advanced operations

Integration of Hive with HBase

  • Create a table and insert data into it
  • Integration of Hive with HBase
  • HBase Mapping

Deep Dive into HBase

  • Input Data into HBase
  • File Loading
  • HDFS File
  • HBase handling files in File System
  • WAL
  • Seek Vs Transfer
  • HBase ACID Properties

Got a question for us? Please mention it in the comments section and we will get back to you.

 

0 responses on "Deep dive into Java Client API for HBase and its associated classes"

Leave a Message

Your email address will not be published. Required fields are marked *