This article is a mirror article of machine translation, please click here to jump to the original article.

View: 14155|Reply: 1

[Source] Spring Boot Project Using the Latest HBase Java API to Operate HBase 2.x Detailed Description

[Copy link]
Posted on 1/9/2019 1:57:39 PM | | | |
1. Configure the HBase 2.x environment

Here, because it is just to test the use of HBase's Java API, I only deployed a stand-alone version of the service in the local virtual machine, and the production environment can deploy the cluster mode by itself. It should also be noted that some of the listening ports of the stand-alone version of the HBase service are bound to the 127.0.0.1 of the virtual machine, which makes it impossible to connect to HBase using the Java API on the physical machine. My solution is to use SecureCRT to configure the relevant port mapping, the specific mapping information is as follows:



2. Detailed explanation of using the latest Java API to operate HBase 2.x

(1) Add the following dependencies to the Spring Boot/Spring Cloud project:

(2) Basic operations related to HBase:



(3) Add HBase configuration information:


The specific attributes used are as follows:

(4) Test the above basic methods:

i) Deleting, creating tables, and basic queries:


After running the unit tests, the output is as follows:

ii) Query that specifies startRowKey and stopRowKey:

This query is generally used when the RowKey is continuously incremented and only a part of the data is queried (such as pagination):


After running the unit tests, the output is as follows:

iii) Get all table names:

After running the unit tests, the output is as follows:

iv) Get data for multiple versions of a specified cell:

After running the unit tests, the output is as follows:

Note: Because HBase only saves one version by default, the effect is not visible here.

v) Query data based on row key filters:


After running the unit tests, the output is as follows:

vi) Query data based on column name filter:

After running the unit tests, the output is as follows:



vii) Query data containing specific characters in row keys:

After running the unit tests, the output is as follows:

viii) Delete the specified column:

After running the unit tests, the output is as follows:

ix) Delete the specified line:

After running the unit tests, the output is as follows:

According to the output, it can be seen that this line of data has indeed been deleted.

x) Delete the specified column family:


After running the unit tests, the output is as follows:

According to the output, it can be found that the column family "back" has been deleted.





Previous:Read/generate Excel files
Next:Just take a look at "Tianwang Town Mansion Secret Talisman"
Posted on 6/5/2019 4:18:18 PM |
Thank you for registering, it is well written, and I have learned.
Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com