设为首页 加入收藏

TOP

hbase rowkey 的设计(二)
2019-09-17 18:53:55 】 浏览:69
Tags:hbase rowkey 设计
rId + timestamp +orderId
3.根据订单号查询
orderNo
4.如果某个商家卖了很多商品,可以如下设计 Rowkey 实现快速搜索
salt + sellerId + timestamp 其中,salt 是随机数。
可以支持的场景:

全表 Scan
按照 sellerId 查询
按照 sellerId + timestamp 查询

金融风控 Rowkey 设计

查询某个用户的用户画像数据
prefix + uid
prefix + idcard
prefix + tele
其中 prefix = substr(md5(uid),0 ,x), x 取 5-6。uid、idcard以及 tele 分别表示用户唯一标识符、身份证、手机号码。

车联网 Rowkey 设计

查询某辆车在某个时间范围的交易记录
carId + timestamp
某批次的车太多,造成热点
prefix + carId + timestamp 其中 prefix = substr(md5(uid),0 ,x)

查询最近的数据

查询用户最新的操作记录或者查询用户某段时间的操作记录,RowKey 设计如下:
uid + Long.Max_Value - timestamp
支持的场景

查询用户最新的操作记录
Scan [uid] startRow [uid][000000000000] stopRow [uid][Long.Max_Value - timestamp]

查询用户某段时间的操作记录
Scan [uid] startRow [uid][Long.Max_Value – startTime] stopRow [uid][Long.Max_Value - endTime]

如果 RowKey 无法满足我们的需求,可以尝试二级索引。Phoenix、Solr 以及 ElasticSearch 都可以用于构建二级索引。

 

 

 

首页 上一页 1 2 下一页 尾页 2/2/2
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇CentOS 7 MySql 解压版安装配置 下一篇hive介绍、安装配置、表操作基础..

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目