In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)05/31 Report--
This article will explain in detail several solutions for HBase to store time-related multi-column data. The editor thinks it is very practical, so I share it with you for reference. I hope you can get something after reading this article.
Two schemes for storing time-dependent Multi-column data in HBase
The so-called "time-related multi-column data" means that there are multiple attribute data under the same Key, and these data are related to time. Most scenarios are the behavior data corresponding to the Key at different times. In practical applications, there is a lot of this kind of data, such as the collection of babies that users have browsed recently on e-commerce sites, the URL list visited, and so on.
When using HBase to store such data, there are two common scenarios:
Structural design of multi-line single list
Row Key: user identity ID + (Long.MAX_VALUE-timestamp)
Column Family:'cf'
Column Qualifier:''
Value: baby, URL, etc.
Among them, (Long.MAX_VALUE-timestamp) is used as the second half of the Row Key to facilitate access to the recently inserted data. The data under a user ID ID is stored under multiple Row Key, and there is only one Column Qualifier under each Row Key, indicating that the user has a time-related access data (access baby, URL, etc.).
Query mode
1) if you query the records under a specific timestamp, use the user ID ID + (Long.MAX_VALUE-timestamp) for Get lookup.
2) query all the records under a user's ID ID, then search for Scan through Scan.setStartRow (uid) and Scan.setStopRow (uid+1)
3) query N records in the most recent time under a user ID ID, then do Scan search through Scan.setStartRow (uid) and Scan.setStopRow (uid+1), but in order to get only N records, you can set Scan.setCaching (N) to optimize the query and do ResultScanner.next (N) at the same time to get the results.
Single-row multi-list structure design
Row Key: user ID ID
Column Family:'cf'
Column Qualifier: (Long.MAX_VALUE-timestamp)
Value: baby, URL, etc.
Among them, (Long.MAX_VALUE-timestamp) is used as a Column Qualifier to facilitate access to recently inserted data. The data under a user ID ID is stored under a Row Key, and there will be multiple Column Qualifier under each Row Key, indicating all the time-related access data of the user (access baby, URL, etc.).
Query mode
1) query the records under a specific timestamp, then use the user ID ID for Get lookup, and use the Get.addColumn ('cf', (Long.MAX_VALUE-timestamp)) method to limit the Column Qualifier to be queried
2) query all the records under a user ID ID, then directly use the user ID ID for Get search, and add the entire Column Family through the Get.addFamily ('cf') method
3) if you query N records in the most recent time under a user ID ID, you will directly use the user ID ID for Get search, add the entire Column Family through the Get.addFamily ('cf') method, and return a maximum of N records through the ColumnCountGetFilter (int N) restriction.
This is the end of this article on "there are several solutions for HBase to store time-related multi-column data". 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, please 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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.