Get the App
SLTechnology News&Howtos  ›  Servers  › 

What are the design principles of RowKey in HBase

Shulou Source: shulou.com Published: 2022-05-31 21:25:08 09月18日 Update

This article mainly introduces what are the design principles of RowKey in HBase, which can be used for reference by interested friends. I hope you can learn a lot after reading this article.

First, take a look at the three principles of RowKey design.

1, hashing principle, do not use data such as timestamp directly as RowKey, if you really need to use timestamp, you can put it in the low bit, high bit with hash to occupy.

2, the length principle, in fact, the summary is a sentence, rowkey is only a unique identifier, and no more practical significance, so do not do too long, but, I want to say, but, if my rowkey is meaningful, then it is OK to let him grow a little longer?

3, the principle of uniqueness, there is nothing to say, RowKey needs to determine a unique piece of data, so it must be unique.

There is nothing to say about the last two principles. Let's focus on the hash principle and why there is such a suggestion.

In HBase, the table is divided into 1... n Region, which is hosted in the RegionServer. Two important attributes of Region: StartKey and EndKey represent the rowKey scope maintained by Region. When we want to read / write data, if the rowKey falls within a certain start-end key range, then we will locate the target region and read / write to the relevant data.

If we do not set the partition in advance when building the table, HBase will automatically split the table with the increase of data in the table, but there are several problems with this: first, the principle of partitioning may not be what we want; second, when there is relatively little data in the table, the advantages of distributed concurrent processing cannot be fully demonstrated. Third, split operation is actually quite resource-consuming, if the data growth is too fast, it may occur relatively frequently.

So, how is pre-partitioning implemented? let's look at the following statement:

Create 'testtable',' common', 'data', {SPLITS = > [' 1', 2', 3']}

After it is built, we can see the partition distribution of the table in the web page of HBase:

As we can see, we divide a table into four region with 1 region 2 and 3 numbers. The four region are:

X

Tags: Data principles time articles design situation easy to say nothing continuous advantage distributed only time more scope statement face generation different frequent Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Apple Shulou Information vpn Shulou Tech Info NVidia