Compute
Elastic Cloud Server
Huawei Cloud Flexus
Bare Metal Server
Auto Scaling
Image Management Service
Dedicated Host
FunctionGraph
Cloud Phone Host
Huawei Cloud EulerOS
Networking
Virtual Private Cloud
Elastic IP
Elastic Load Balance
NAT Gateway
Direct Connect
Virtual Private Network
VPC Endpoint
Cloud Connect
Enterprise Router
Enterprise Switch
Global Accelerator
Management & Governance
Cloud Eye
Identity and Access Management
Cloud Trace Service
Resource Formation Service
Tag Management Service
Log Tank Service
Config
OneAccess
Resource Access Manager
Simple Message Notification
Application Performance Management
Application Operations Management
Organizations
Optimization Advisor
IAM Identity Center
Cloud Operations Center
Resource Governance Center
Migration
Server Migration Service
Object Storage Migration Service
Cloud Data Migration
Migration Center
Cloud Ecosystem
KooGallery
Partner Center
User Support
My Account
Billing Center
Cost Center
Resource Center
Enterprise Management
Service Tickets
HUAWEI CLOUD (International) FAQs
ICP Filing
Support Plans
My Credentials
Customer Operation Capabilities
Partner Support Plans
Professional Services
Analytics
MapReduce Service
Data Lake Insight
CloudTable Service
Cloud Search Service
Data Lake Visualization
Data Ingestion Service
GaussDB(DWS)
DataArts Studio
Data Lake Factory
DataArts Lake Formation
IoT
IoT Device Access
Others
Product Pricing Details
System Permissions
Console Quick Start
Common FAQs
Instructions for Associating with a HUAWEI CLOUD Partner
Message Center
Security & Compliance
Security Technologies and Applications
Web Application Firewall
Host Security Service
Cloud Firewall
SecMaster
Anti-DDoS Service
Data Encryption Workshop
Database Security Service
Cloud Bastion Host
Data Security Center
Cloud Certificate Manager
Edge Security
Managed Threat Detection
Blockchain
Blockchain Service
Web3 Node Engine Service
Media Services
Media Processing Center
Video On Demand
Live
SparkRTC
MetaStudio
Storage
Object Storage Service
Elastic Volume Service
Cloud Backup and Recovery
Storage Disaster Recovery Service
Scalable File Service Turbo
Scalable File Service
Volume Backup Service
Cloud Server Backup Service
Data Express Service
Dedicated Distributed Storage Service
Containers
Cloud Container Engine
SoftWare Repository for Container
Application Service Mesh
Ubiquitous Cloud Native Service
Cloud Container Instance
Databases
Relational Database Service
Document Database Service
Data Admin Service
Data Replication Service
GeminiDB
GaussDB
Distributed Database Middleware
Database and Application Migration UGO
TaurusDB
Middleware
Distributed Cache Service
API Gateway
Distributed Message Service for Kafka
Distributed Message Service for RabbitMQ
Distributed Message Service for RocketMQ
Cloud Service Engine
Multi-Site High Availability Service
EventGrid
Dedicated Cloud
Dedicated Computing Cluster
Business Applications
Workspace
ROMA Connect
Message & SMS
Domain Name Service
Edge Data Center Management
Meeting
AI
Face Recognition Service
Graph Engine Service
Content Moderation
Image Recognition
Optical Character Recognition
ModelArts
ImageSearch
Conversational Bot Service
Speech Interaction Service
Huawei HiLens
Video Intelligent Analysis Service
Developer Tools
SDK Developer Guide
API Request Signing Guide
Terraform
Koo Command Line Interface
Content Delivery & Edge Computing
Content Delivery Network
Intelligent EdgeFabric
CloudPond
Intelligent EdgeCloud
Solutions
SAP Cloud
High Performance Computing
Developer Services
ServiceStage
CodeArts
CodeArts PerfTest
CodeArts Req
CodeArts Pipeline
CodeArts Build
CodeArts Deploy
CodeArts Artifact
CodeArts TestPlan
CodeArts Check
CodeArts Repo
Cloud Application Engine
MacroVerse aPaaS
KooMessage
KooPhone
KooDrive

Java APIs

Updated on 2022-07-11 GMT+08:00

API Usage Suggestions

  • org.apache.hadoop.hbase.Cell rather than org.apache.hadoop.hbase.KeyValue is recommended as the KV data object.
  • It is recommended that Connection connection = ConnectionFactory.createConnection(conf) be used to create a connection. The HTablePool is abandoned.
  • org.apache.hadoop.hbase.mapreduce rather than org.apache.hadoop.hbase.mapred is recommended.
  • You are advised to obtain the HBase client operation object using the getAdmin() method of the constructed Connection object.

Common HBase APIs

Common HBase Java classes are as follows:

  • Interface class Admin: It is the core class of HBase client applications, which encapsulates APIs for HBase management, such as table creation and table deletion. For details, see Table 1.
  • Interface class Table: It is a class for HBase read/write, which encapsulates APIs for reading and writing HBase tables. For details, see Table 2.
Table 1 org.apache.hadoop.hbase.client.Admin

Method

Description

boolean tableExists(final TableName tableName)

This method is used to check whether a specified table exists. If the table exists in the hbase:meta table, true is returned. Otherwise, false is returned.

HTableDescriptor[] listTables(String regex)

This method is used to view the user table that complies with the specified regular expression format. There are two other overload methods, one with the input parameter type of Pattern, and the other with the empty input parameter. When the input parameter is empty, all user tables are queried by default.

HTableDescriptor[] listTables(final Pattern pattern, final boolean includeSysTables)

The function of this method is similar to that of the previous method. Users can use this method to specify whether the returned result contains the system table. The previous method returns only the user table.

TableName[] listTableNames(String regex)

This method is used to view the user table that complies with the specified regular expression format. There are two other overload methods, one with the input parameter type of Pattern, and the other with the empty input parameter. When the input parameter is empty, all user tables are queried by default. The function of this method is similar to that of listTables. The only difference is that this method returns TableName[].

TableName[] listTableNames(final Pattern pattern, final boolean includeSysTables)

The function of this method is similar to that of the previous method. Users can use this method to specify whether the returned result contains the system table. The previous method returns only the user table.

void createTable(HTableDescriptor desc)

This method is used to create a table with only one region.

void createTable(HTableDescriptor desc, byte[] startKey, byte[] endKey, int numRegions)

This method is used to create a table with a specified number of regions. The endKey of the first region is the StartKey, and the StartKey of the last region is the endKey. If there are a large number of regions, the invoking of this method may time out.

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

This method is used to create a table. The number of regions in the table and the StartKey of each region are determined by splitKeys. If there are a large number of regions, the invoking of this method may time out.

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

This method is used to create a table. The number of regions in the table and the StartKey of each region are determined by splitKeys. This method uses asynchronous invoking, and does not wait for the created table to be online.

void deleteTable(final TableName tableName)

This method is used to delete a specified table.

public void truncateTable(final TableName tableName, final boolean preserveSplits)

This method is used to re-create a specified table. If the second parameter is set to true, the region of the reconstructed table is the same as that of the previous table. Otherwise, there is only one region.

void enableTable(final TableName tableName)

This method is used to enable a specified table. If there are a large number of regions in a table, the invoking of this method may time out.

void enableTableAsync(final TableName tableName)

This method is used to enable a specified table. This method uses asynchronous invoking, and does not wait for all regions to be online.

void disableTable(final TableName tableName)

This method is used to disable a specified table. If there are a large number of regions in a table, the invoking of this method may time out.

void disableTableAsync(final TableName tableName)

This method is used to disable a specified table. This method uses asynchronous invoking, and does not wait for all regions to be offline.

boolean isTableEnabled(TableName tableName)

This method is used to check whether a table is enabled. This method can be used with the enableTableAsync method to check whether the operation of enabling a table is complete.

boolean isTableDisabled(TableName tableName)

This method is used to check whether a table is disabled. This method can be used with the disableTableAsync method to check whether the operation of disabling a table is complete.

void addColumn(final TableName tableName, final HColumnDescriptor column)

This method is used to add a column family to a specified table.

void deleteColumn(final TableName tableName, final HColumnDescriptor column)

This method is used to delete a specified column family from a specified table.

void modifyColumn(final TableName tableName, final HColumnDescriptor column)

This method is used to modify a specified column family.

Table 2 org.apache.hadoop.hbase.client.Table

Method

Description

boolean exists(Get get)

This method is used to check whether the specified rowkey exists in the table.

boolean[] existsAll(List<Get> gets)

This method is used to check whether the specified rowkey exists in the table. The returned Boolean array result corresponds to the input parameter position.

Result get(Get get)

This method is used to read data based on the specified RowKey.

Result[] get(List<Get> gets)

This method is used to read data in batches by specifying a batch of RowKeys.

ResultScanner getScanner(Scan scan)

This method is used to obtain a scanner object in the table. The query parameters can be specified by the input parameter scan, including StartRow, StopRow, and caching.

void put(Put put)

This method is used to write a data record to the table.

void put(List<Put> puts)

This method is used to write a batch of data records to the table.

void close()

This method is used to release the resources held by the table object.

NOTE:

Table 1 and Table 2 list only some common methods. F

We use cookies to improve our site and your experience. By continuing to browse our site you accept our cookie policy. Find out more

Feedback

Feedback

Feedback

0/500

Selected Content

Submit selected content with the feedback