Hbase the definitive guide - Advanced Usage章 阅读札记

本文深入探讨了HBase的高级用法,包括表设计、部分键值扫描、分页、时间序列数据处理及BloomFilter应用。重点介绍了如何通过优化设计提升性能,以及在不同场景下选择合适的技术策略。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

hbase的高级用法 - 读书札记。

 

2.hbase表的两种设计: (tall-narrow and flat-wide)高而窄型设计、宽而平型设计。

前者拥有较少的列和较多的行。后者行少而列多。考虑到keyrow查询粒度的问题,建议把cell中的值提取到key中,

尤其是当cell中的值需要查询时。另外,hbase仅支持行边界分裂,因此前者能很好支持,而flat-wide的设计中,

如果一行数据太大,超过region大小就会和region分裂策略相互冲突。

 

3.部分键值扫描器:通过设置startrow 和endrow来查询一段RowKey。(startrow + 1是一个很好的技巧)

 

4.分页:分页可通过partial key scan实现,原理是先通过设置start key和stop key确定一个范围,然后再在客户端

通过偏移量(Offset)和大小限制(limit)来实现分页,这和普通的数据库分页是有区别的。

或者使用PageFilter或是ColumnPaginationFilter也可实现分页。

 

5.时间序列数据:具有时间顺序的数据,一般RowKey代表了时间,这种单调递增的数据,造成所有进入的数据

都被写到一个region而不是分散到各个region上,这将导致集群的效率降低(数据更新将集中在一个特定的region上)。

解决的办法是在时间前面加上非序列的前缀,如:


byte prefix = (byte) (Long.hashCode(timestamp) % <number of regionservers>);
byte[] rowkey = Bytes.add(Bytes.toBytes(prefix), Bytes.toBytes(timestamp);
 

 

但这样一来RowKey的范围就会扩散。

 

在组合键的情况下可以考虑把时间戳放在次要位置。带来的问题是按照时间范围的查询难以进行。好处是某记录

是时间顺序(倒序)的。

 

总得来说键的设计,键值越随机,写性能越好,键值越连续,读性能约好。

 

#时间排序关系,FamilyColumn的每个Column都是排序的,把时间戳当做列名存储。可以把它当做二级索引的替代,关系数据库中的二级索引

可以通过多Column进行模拟,尽管这不是推荐的设计。但是对于只有少量索引的情况是有效的。

 

6.bloom Filter:

三种方式:


Type Description
NONE Disables the filter (default)
ROW Use the row key for the filter
ROWCOL Use the row key and column key (family+qualifier) for the filter
 

原文引用如下: 

The final question is whether to use a row or a row+column Bloom filter. The answer depends on your usage pattern. If you are doing only row scans, having the more specific row+column filter will not help at all: having a row-level Bloom filter enables you to narrow down the number of files that need to be checked, even when you do row+column read operations, but not the other way around.

The row+column Bloom filter is useful when you cannot batch updates for a specific row, and end up with store files which all contain parts of the row. The more specific row+column filter can then identify which of the files contain the data you are re-questing. Obviously, if you always load the entire row, this filter is once again hardly useful, as the region server will need to load the matching block out of each file anyway.

Since the row+column filter will require more storage, you need to do the math to
determine whether it is worth the extra resources. It is also interesting to know that there is a maximum number of elements a Bloom filter can hold. If you have too many cells in your store file, you might exceed that number and would need to fall back to the row-level filter.

Depending on your use case, it may be useful to enable Bloom filters, to increase the overall performance of your system. If possible, you should try to use the row-level Bloom filter, as it strikes a good balance between the additional space requirements and the gain in performance coming from its store file selection filtering. Only resort to the more costly row+column Bloom filter when you would otherwise gain no ad-vantage from using the row-level one.
 

 

也就是说如果要使用bloom Filter,尽量把它加在row级别上,而不是row+col都加,第三中ROWCOL的方式将

占用最多的磁盘和内存。

 

如果你只是做Scan,row级别的bloom Filter就足够了,row+col毫无用处。

一、综合实战—使用极轴追踪方式绘制信号灯 实战目标:利用对象捕捉追踪和极轴追踪功能创建信号灯图形 技术要点:结合两种追踪方式实现精确绘图,适用于工程制图中需要精确定位的场景 1. 切换至AutoCAD 操作步骤: 启动AutoCAD 2016软件 打开随书光盘中的素材文件 确认工作空间为"草图与注释"模式 2. 绘图设置 1)草图设置对话框 打开方式:通过"工具→绘图设置"菜单命令 功能定位:该对话框包含捕捉、追踪等核心绘图辅助功能设置 2)对象捕捉设置 关键配置: 启用对象捕捉(F3快捷键) 启用对象捕捉追踪(F11快捷键) 勾选端点、中心、圆心、象限点等常用捕捉模式 追踪原理:命令执行时悬停光标可显示追踪矢量,再次悬停可停止追踪 3)极轴追踪设置 参数设置: 启用极轴追踪功能 设置角度增量为45度 确认后退出对话框 3. 绘制信号灯 1)绘制圆形 执行命令:"绘图→圆→圆心、半径"命令 绘制过程: 使用对象捕捉追踪定位矩形中心作为圆心 输入半径值30并按Enter确认 通过象限点捕捉确保圆形位置准确 2)绘制直线 操作要点: 选择"绘图→直线"命令 捕捉矩形上边中点作为起点 捕捉圆的上象限点作为终点 按Enter结束当前直线命令 重复技巧: 按Enter可重复最近使用的直线命令 通过圆心捕捉和极轴追踪绘制放射状直线 最终形成完整的信号灯指示图案 3)完成绘制 验证要点: 检查所有直线是否准确连接圆心和象限点 确认极轴追踪的45度增量是否体现 保存绘图文件(快捷键Ctrl+S)
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值