hbase建表预分区的2种方法

以下案例建表并设置预分区,分别测试以下2种方法

1.固定散列

示例:rowkey以日期为前缀

create 'test','cf1', SPLITS => '202401', '202402', '202403'

put 'test','20240101','cf1:name','20240101'

put 'test','20240102','cf1:name','20240102'

put 'test','20240103','cf1:name','20240103'

put 'test','20240201','cf1:name','20240201'

put 'test','20240202','cf1:name','20240202'

put 'test','20240203','cf1:name','20240203'

put 'test','20240301','cf1:name','20240301'

put 'test','20240302','cf1:name','20240302'

put 'test','20240303','cf1:name','20240303'

put 'test','20240304','cf1:name','20240304'

都分发到对应的region

Table Regions

Name Region Server Start Key End Key Locality Requests

test,1714377792028.5582f2cefddffb29a9cb8a47b404df63. whtpiodscshd02t,21302,1710927704067 202401 0.0 0

test,202401,1714377792028.fc66ef2c38740a635f5cea810d7f4d8d. whtpiodscshd01t,21302,1710927618816 202401 202402 0.0 3

test,202402,1714377792028.e72ba47f141297e012ab350cba56ad5c. whtpiodscshd03t,21302,1710927771892 202402 202403 0.0 3

test,202403,1714377792028.cd19ee74662ef8ba393464da96213aba. whtpiodscshd02t,21302,1710927704067 202403 0.0 4

2.哈希散列

Hbase自带了两种pre-split的算法,分别是HexStringSplit和UniformSplit

1.HexStringSplit算法

示例1:

create 'test2', {NAME => 'cf1'},{NUMREGIONS => 4, SPLITALGO => 'HexStringSplit'}

put 'test2','20240101','cf1:name','20240101'

put 'test2','20240102','cf1:name','20240102'

put 'test2','20240103','cf1:name','20240103'

put 'test2','20240201','cf1:name','20240201'

put 'test2','20240202','cf1:name','20240202'

put 'test2','20240203','cf1:name','20240203'

put 'test2','20240301','cf1:name','20240301'

put 'test2','20240302','cf1:name','20240302'

put 'test2','20240303','cf1:name','20240303'

put 'test2','20240304','cf1:name','20240304'

Table Regions

Name Region Server Start Key End Key Locality Requests

test2,1714382074838.ad061d93d07dea90c587ce00e5ad56c0. whtpiodscshd03t,21302,1710927771892 40000000 0.0 10

test2,40000000,1714382074838.c803b1e07c2390095f67041d16771906. whtpiodscshd01t,21302,1710927618816 40000000 80000000 0.0 0

test2,80000000,1714382074838.c17c9a422fece545f968b4652a8d049a. whtpiodscshd02t,21302,1710927704067 80000000 c0000000 0.0 0

test2,c0000000,1714382074838.77e83f95f8fa8dc42210a666dc76f126. whtpiodscshd01t,21302,1710927618816 c0000000 0.0 0

2.UniformSplit算法

示例2:

create 'test3', {NAME => 'cf1'},{NUMREGIONS => 4, SPLITALGO => 'UniformSplit'}

put 'test3','acdzdf4ae5rew','cf1:name','acdzdf4ae5rew'

put 'test3','acdzdfaczerew','cf1:name','acdzdfaczerew'

put 'test3','edddddddddfdd','cf1:name','edddddddddfdd'

put 'test3','acdzdfacaerew','cf1:name','acdzdfacaerew'

put 'test3','acdzd12344rew','cf1:name','acdzd12344rew'

put 'test3','acdzd44caerew','cf1:name','acdzd44caerew'

put 'test3','acdzdfa123rew','cf1:name','acdzdfa123rew'

put 'test3','acdzdfaxaerew','cf1:name','acdzdfaxaerew'

put 'test3','acdzdfadfcrew','cf1:name','acdzdfadfcrew'

put 'test3','acdzdfac1erew','cf1:name','acdzdfac1erew'

Table Regions

Name Region Server Start Key End Key Locality Requests

test3,1714382196221.51c3306c9ef13a9251fb0b184c077711. whtpiodscshd02t,21302,1710927704067 @\x00\x00\x00\x00\x00\x00\x00 0.0 10

test3,@\x00\x00\x00\x00\x00\x00\x00,1714382196221.17b5d102fee381c30255e51692b3050d. whtpiodscshd01t,21302,1710927618816 @\x00\x00\x00\x00\x00\x00\x00 \x80\x00\x00\x00\x00\x00\x00\x00 0.0 10

test3,\x80\x00\x00\x00\x00\x00\x00\x00,1714382196221.4348f72d52953c670f0cfb90a329ad2b. whtpiodscshd03t,21302,1710927771892 \x80\x00\x00\x00\x00\x00\x00\x00 \xC0\x00\x00\x00\x00\x00\x00\x00 0.0 0

test3,\xC0\x00\x00\x00\x00\x00\x00\x00,1714382196221.50b797c3caaf12d54068e323e8e65ba4. whtpiodscshd01t,21302,1710927618816 \xC0\x00\x00\x00\x00\x00\x00\x00 0.0 0

相关推荐
●VON4 小时前
鸿蒙Flutter实战:分类管理页BottomSheet CRUD
数据库·flutter·华为·harmonyos·鸿蒙
Cosolar4 小时前
Chroma向量库面试学习指南
数据库·人工智能·面试·职场和发展·数据库架构
方也_arkling5 小时前
【Java-Day08】static / final / 枚举
java·开发语言
橙淮5 小时前
Spring Bean作用域与生命周期全解析
java·spring
Chengbei115 小时前
一站式源码安全检测工具、云安全 / APP / 小程序源码敏感信息递归多层目录扫描AK、JWT、手机号、身份证等敏感信息
java·开发语言·安全·web安全·网络安全·系统安全·安全架构
llz_1125 小时前
web-第一次课后作业
java·开发语言·idea
企服AI产品测评局5 小时前
Agent适配信创环境实测:企业级自动化如何实现国产操作系统与数据库全兼容?
运维·数据库·人工智能·ai·chatgpt·自动化
秋95 小时前
Java项目运行5天左右自动宕机:系统性定位与解决方案
java·开发语言·python
小江的记录本6 小时前
【JVM虚拟机】垃圾回收GC:垃圾收集器:CMS:核心原理、回收流程、优缺点、废弃原因(附《思维导图》+《面试高频考点清单》)
java·jvm·后端·python·spring·面试·maven
cfm_29146 小时前
Redis数据安全性解析
数据库·redis·缓存