Basic HBase Java Classes and Methods – Part 2: HBase Shell

For the purpose of these exercises we will be working with a basic table which as two column families.  The first column family is “personal” and will contain first_name, last_name, age, gender, martial_status.  The second column family is “professional” and will contain “occupation” and “education”.

We will walk through all of the steps from creating the table, column families, populating data, changing data, deleting data and dropping the table.  We will first show you this in the HBase shell so you can be familiar with the data we are working with.  In Part 3 we will start to do these tasks programmatically using Java.

We are making a very brisk journey through the shell, with little to no explanation of the various parts of HBase, we assume you have learned the basics from reading the documentation.  Our goal is to just so some basic common HBase table operations using the shell, and then replicate it using Java.

Our employee table will look like so:

personal professional
ID first_name last_name age gender martial_status occupation education

First we fire up the HBase shell

We can request the basic status from HBase

We ask it who we are, similar to the whoami UNIX command, and get a list of any tables

We see that there are no tables.  We create the employee table with two column families, personal and professional.

We can use the describe command to give us more copious information about the table.  Many of these parameters have to do with the underlaying Hadoop layer and are not important for our exercises.

We can see we have no actual records in the table

Let’s insert a single record with an ID (row key) of 1.

You can see we inserted a single record with a column first_name inside of the column family personal.  There are no constraints in our table, so we can leave entire columns out or create new ones on the fly.

We will add a bunch more data

Notice I inserted the above record using a row key that was not 2, instead I skipped 2.  HBase doesn’t care what you make the row key, it can be a string, number, even an array.

Now that we have inserted information regarding three employees, lets take a look at our table.

We can easily make changes to any information:

We can delete just a single cell if we wish

We can use the exists command to see if a table exists

We have to disable a table before we can drop it. Disabling a table flushes all the data in memory to disk.

We can see there are no more tables

We will be repeating these commands in the next Part using Java in Basic HBase Java Classes and Methods – Part 3: Table Creation

This entry was posted in Data Analytics and tagged , . Bookmark the permalink.

Leave a Reply