Code360 powered by Coding Ninjas X Naukri.com. Code360 powered by Coding Ninjas X Naukri.com
Table of contents
1.
Introduction
2.
Class HBaseAdmin
3.
Methods and Description
4.
Class Descriptor 
5.
FAQs
6.
Key Takeaways
Last Updated: Mar 27, 2024

HBase Admin API

Master Python: Predicting weather forecasts
Speaker
Ashwin Goyal
Product Manager @

Introduction

Apache HBase provides a Java API for interacting with HBase and performing various activities. 

As HBase is written in Java, it can communicate with Java API. The Java API, on the other hand, is the quickest way to interface with HBase. As a result, we'll describe the Java Admin API linked below, which covers managing tables.

The class representing the Admin in HBase, named HBase Admin API, will be introduced in this blog, "HBase Admin API." The role of the Class Descriptor in HBase will also be discussed, along with the methods and their descriptions.

Class HBaseAdmin

The admin class in HBase is called as HBaseAdmin, which is part of the org.apache.hadoop.hbase.client package. Using this class, we may execute the duties of an administrator. The Connection.getAdmin() method can be used to obtain an instance of Admin.

Get the tech career you deserve, faster!
Connect with our expert counsellors to understand how to hack your way to success
User rating 4.7/5
1:1 doubt support
95% placement record
Akash Pal
Senior Software Engineer
326% Hike After Job Bootcamp
Himanshu Gusain
Programmer Analyst
32 LPA After Job Bootcamp
After Job
Bootcamp

Methods and Description

The methods and descriptions available in HBase Admin API are as follows:

void createTable(HTableDescriptor desc)
This method creates a new table.

void createTable(HTableDescriptor desc, byte[ ][ ] splitKeys)
This method creates a new table with an initial set of empty regions determined by the split keys sent in.

void createTable(HTableDescriptor desc, byte[ ] startKey, byte[ ] endKey, int numRegions)
It is used to create a new table with the specified number of regions.

void createTableAsync(HTableDescriptor desc, byte[ ][ ] splitKeys)
It is used to create a new table but does not block and wait for it to come online.

void deleteColumn(byte[ ] tableName, String columnName)
We utilise this method to delete a column from a table.

void deleteColumn(String tableName, String columnName)
This method helps in the deletion of a column from a table.

void deleteTable(TableName tableName)
This method is used to delete a table.

To Summarize:

  Methods

Description

void createTable(HTableDescriptor desc)

Creates a new table.

void createTable(HTableDescriptor desc, byte[][] splitKeys)

This method creates a new table with an initial set of empty regions determined by the split keys sent in.

void deleteColumn(byte[] tableName, String columnName)

Deletes a column from a table.

void deleteColumn(String tableName, String columnName)

Deletes a column from a table.

void deleteTable(String tableName)

Deletes a table.

Class Descriptor 

As the name implies, it contains information about an HBase table, such as:

  • Regarding all of the column families' descriptions.
  • If the table is a catalogue table or not.
  • Is the table is read-only?
  • The mem store's maximum size
  • It also indicates when the region split should take place.
  • The co-processors involved with it.

Let's have a look at its Constructor and Summary

Constructor Description
HTableDescriptor(TableName name) In general, it creates a table descriptor that specifies a TableName object.

Let's have a look at its Methods and Description

Methods Description
HTableDescriptor addFamily(HColumnDescriptor family) This is used to add a column family to the given descriptor.

 

Must Read Apache Server

FAQs

  1. What is HBase?
    HBase is a column-oriented database with a configurable database structure. It mainly works on top of HDFS and also supports MapReduce tasks. HBase also supports various high-level languages for data processing.
     
  2. Why do we use HBase Admin API?
    HBaseAdmin is a class that represents an administrator. The org.apache.hadoop.hbase.client package contains this class. You can use this class to conduct administrative duties. The Connection.getAdmin() method can be used to obtain an instance of Admin.
     
  3. What are the methods and descriptions available in HBase Admin API?
    The methods and descriptions available in HBase Admin API are as follows:

  Methods

Description

void createTable(HTableDescriptor desc)

Creates a new table.

void createTable(HTableDescriptor desc, byte[][] splitKeys)

This method creates a new table with an initial set of empty regions determined by the split keys sent in.

void deleteColumn(byte[] tableName, String columnName)

Deletes a column from a table.

void deleteColumn(String tableName, String columnName)

Deletes a column from a table.

void deleteTable(String tableName)

Deletes a table.

Key Takeaways

HBase is a column-oriented database with a configurable database structure. It mainly works on top of HDFS and also supports MapReduce tasks. HBase also supports various high-level languages for data processing.

In this blog, we have seen the whole concept of HBase Admin API. We have learned about Class HBase Admin, Methods and Description, and Class Descriptor.

Also, try Coding Ninjas Studio to practice programming problems for your complete interview preparation. Don't stop here, Ninja; check out the Top 100 SQL Problems to get hands-on experience with frequently asked interview questions and land your dream job.

Previous article
HBase Table Management
Next article
HBase Client API
Live masterclass