Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How Hbase sorts and compares sizes

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)05/31 Report--

This article is to share with you about how Hbase is sorted and sized. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.

Rowkey is the primary key of the row, and hbase can only use a rowkey, or a rowkey range, scan, to find data. So the design of rowkey is very important, related to the query efficiency of your application layer. We know that rowkey is sorted in dictionary order. And the stored bytecode, dictionary order, we know that if it is a letter, that is the order of letters, for example, if there are two rowkey,rowkey1:aaa222,rowkey2:bbb111, then rowkey1 is ranked before rowkey2, because according to the dictionary, a comes before b, if the first bit of rowkey2 is also a, then compare it according to the second bit, if it is the same, the third is the same, and the latter is the same. This understands that when we query according to the range of rowkey, we generally know startRowkey. If we only send startRowKey: d through scan, then we have checked all the data that are larger than d, and we only need data that starts with d, then we have to restrict it through endRowKey. We can set endRowKey to start with: d, and then set it according to your rowkey combination, usually Gaby startKey. For example, rowkey is designed to: user ID- date, then check the data of a user for a certain day, the startKEY is 3231-201212, the endKey is: 3231-201213, then you will find the data of 3231 users on the 20121212 day.

Column key

After column key is rowkey, the data is sorted by rowkey dictionary, and if the rowkey is the same, it is sorted by column key, and also by dictionary.

We should learn to take advantage of this when designing table. Like our inbox. We sometimes need to sort by theme, so we can set the theme to our column key, that is, the design as the columnFamily+ theme.

Timestamp

The timestamp timestamp, which is the third dimension, is sorted in descending order, meaning that the latest data comes first.

The comparison size in hbase is also compared by dictionary. In hbase, 9 > 800, so when we compare size, we should pay attention to zero padding and keep the length of the number the same.

Thank you for reading! This is the end of the article on "how to sort and compare Hbase". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it for more people to see!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report