HBase Shell的应用案例

电商( eshop)平台具有海量数据、高并发访问、高速读写等特征,适合使用HBase分布式数据库进行数据存储。本节通过一个 HBase在电商平台的应用案例,熟练掌握并综合运用HBase Shell命令行终端提供的各种操作命令。

一、电商(eshop)平台的逻辑数据模型

在HBase创建一个自定义命名空间eshop,用于存放电商平台的用户表shopping(客户商品订单表)。用户表shopping 包括customer、order和 item共三个列族,用逻辑数据模型来表示表中存放的数据。如表1所示:

表1 用逻辑数据模型表示电商系统用户表shopping中存放的数据
行键(RowKey)列族:customer列族:order列族:item
列限定符单元格值列限定符单元格值列限定符单元格值
s001nameJacknumber1item_nameiphone8
s001phone00000000001datetime2020-4-21price8000.00 
s001addressWuHanpay-statenot payed
s001levelnormal
s002nameTomnumber2item_nameHAWEI MATE X2
s002phone00000000002datetime2020-4-22price6000.00 
s002addressBeiJing
s002preferencee-product
s003nameMikenumber3item_nameXIAO MI 11
s003phone00000000003datetime2020-4-23price5000.00 
s003addressShangHai
s003age20
s004nameLucynumber4item_nameLancome
s004phone00000000004datetime2020-4-23price10000.00 
s004addressHangZhoupay-statepayed
s004preferencecosmeticspost-staterecieved
s004levelVIP
s005nameLilynumber10item_nameLV
s005phone00000000005datetime2020-4-23price20000.00 
s005preferencehandbagpay-statepayed
s005levelVIPpost-statedelivered
s005emailabc@qq.com

二、使用HBase Shell操作电商平台数据

1.对电商平台数据执行简单读写操作

1)创建一个名称为eshop的名字空间,并列出HBase系统所有的名字空间。

hbase:003:0> create_namespace 'eshop'
Took 3.5909 seconds                                                                            
hbase:004:0> list_namespace
NAMESPACE                                                                                      
default                                                                                        
eshop                                                                                          
hbase                                                                                          
3 row(s)
Took 0.0606 seconds

2)在eshop名字空间中创建表名为shopping的用户表,包含1个列族customer;再列出HBase的所有数据表。

hbase:012:0> create 'eshop:shopping','customer'
2024-03-22 01:33:35,528 INFO  [main] client.HBaseAdmin (HBaseAdmin.java:postOperationResult(3591)) - Operation: CREATE, Table Name: eshop:shopping, procId: 216 completed
Created table eshop:shopping
Took 2.5136 seconds                                                                            
=> Hbase::Table - eshop:shopping
hbase:013:0> list
TABLE                                                                                          
eshop:shopping                                                                                 
1 row(s)
Took 0.0670 seconds                                                                            
=> ["eshop:shopping"]

3)给eshop 名字空间中的shopping表增加两个新的列族order和 item;再查看其表格结构。

hbase:018:0> alter 'eshop:shopping','order','item'
Updating all regions with the new schema...
1/1 regions updated.
Done.
Took 3.4106 seconds                                                                            
hbase:019:0> desc 'eshop:shopping'
Table eshop:shopping is ENABLED                                                                
eshop:shopping, {TABLE_ATTRIBUTES => {METADATA => {'hbase.store.file-tracker.impl' => 'DEFAULT'
}}}                                                                                            
COLUMN FAMILIES DESCRIPTION                                                                    
{NAME => 'customer', INDEX_BLOCK_ENCODING => 'NONE', VERSIONS => '1', KEEP_DELETED_CELLS => 'FA
LSE', DATA_BLOCK_ENCODING => 'NONE', TTL => 'FOREVER', MIN_VERSIONS => '0', REPLICATION_SCOPE =
> '0', BLOOMFILTER => 'ROW', IN_MEMORY => 'false', COMPRESSION => 'NONE', BLOCKCACHE => 'true',BLOCKSIZE => '65536 B (64KB)'}                                                                {NAME => 'item', INDEX_BLOCK_ENCODING => 'NONE', VERSIONS => '1', KEEP_DELETED_CELLS => 'FALSE'
, DATA_BLOCK_ENCODING => 'NONE', TTL => 'FOREVER', MIN_VERSIONS => '0', REPLICATION_SCOPE => '0
', BLOOMFILTER => 'ROW', IN_MEMORY => 'false', COMPRESSION => 'NONE', BLOCKCACHE => 'true', BLO
CKSIZE => '65536 B (64KB)'}                                                                    {NAME => 'order', INDEX_BLOCK_ENCODING => 'NONE', VERSIONS => '1', KEEP_DELETED_CELLS => 'FALSE
', DATA_BLOCK_ENCODING => 'NONE', TTL => 'FOREVER', MIN_VERSIONS => '0', REPLICATION_SCOPE => '
0', BLOOMFILTER => 'ROW', IN_MEMORY => 'false', COMPRESSION => 'NONE', BLOCKCACHE => 'true', BL
OCKSIZE => '65536 B (64KB)'}                                                                   3 row(s)

4)先删除 shopping表后再重新创建shopping表,包含3个列族customer,order和 item。

hbase:020:0> disable 'eshop:shopping'
2024-03-22 01:38:46,086 INFO  [main] client.HBaseAdmin (HBaseAdmin.java:rpcCall(926)) - Started disable of eshop:shopping
2024-03-22 01:38:46,764 INFO  [main] client.HBaseAdmin (HBaseAdmin.java:postOperationResult(3591)) - Operation: DISABLE, Table Name: eshop:shopping, procId: 228 completed
Took 0.7314 seconds                                                                            
hbase:021:0> drop 'eshop:shopping'
2024-03-22 01:38:58,599 INFO  [main] client.HBaseAdmin (HBaseAdmin.java:postOperationResult(3591)) - Operation: DELETE, Table Name: eshop:shopping, procId: 231 completed
Took 0.4091 seconds                                                                            
hbase:022:0> list
TABLE                                                                                          
0 row(s)
Took 0.0491 seconds                                                                            
=> []
hbase:023:0> create 'eshop:shopping','customer','order','item'
2024-03-22 01:39:52,129 INFO  [main] client.HBaseAdmin (HBaseAdmin.java:postOperationResult(3591)) - Operation: CREATE, Table Name: eshop:shopping, procId: 232 completed
Created table eshop:shopping
Took 2.2332 seconds                                                                            
=> Hbase::Table - eshop:shopping

5)修改shopping表的表级别属性,将文件大小最大值修改为134217728字节。

hbase:024:0> alter 'eshop:shopping',MAX_FILESIZE=>134217728
Updating all regions with the new schema...
1/1 regions updated.
Done.
Took 2.2104 seconds

6)描述shopping表的列族属性信息。

hbase:025:0> desc 'eshop:shopping'
Table eshop:shopping is ENABLED                                                                
eshop:shopping, {TABLE_ATTRIBUTES => {MAX_FILESIZE => '134217728 B (128MB)', METADATA => {'hbas
e.store.file-tracker.impl' => 'DEFAULT'}}}                                                     
COLUMN FAMILIES DESCRIPTION                                                                    
{NAME => 'customer', INDEX_BLOCK_ENCODING => 'NONE', VERSIONS => '1', KEEP_DELETED_CELLS => 'FA
LSE', DATA_BLOCK_ENCODING => 'NONE', TTL => 'FOREVER', MIN_VERSIONS => '0', REPLICATION_SCOPE =
> '0', BLOOMFILTER => 'ROW', IN_MEMORY => 'false', COMPRESSION => 'NONE', BLOCKCACHE => 'true',BLOCKSIZE => '65536 B (64KB)'}                                                                {NAME => 'item', INDEX_BLOCK_ENCODING => 'NONE', VERSIONS => '1', KEEP_DELETED_CELLS => 'FALSE'
, DATA_BLOCK_ENCODING => 'NONE', TTL => 'FOREVER', MIN_VERSIONS => '0', REPLICATION_SCOPE => '0
', BLOOMFILTER => 'ROW', IN_MEMORY => 'false', COMPRESSION => 'NONE', BLOCKCACHE => 'true', BLO
CKSIZE => '65536 B (64KB)'}                                                                    {NAME => 'order', INDEX_BLOCK_ENCODING => 'NONE', VERSIONS => '1', KEEP_DELETED_CELLS => 'FALSE
', DATA_BLOCK_ENCODING => 'NONE', TTL => 'FOREVER', MIN_VERSIONS => '0', REPLICATION_SCOPE => '
0', BLOOMFILTER => 'ROW', IN_MEMORY => 'false', COMPRESSION => 'NONE', BLOCKCACHE => 'true', BL
OCKSIZE => '65536 B (64KB)'}                                                                   3 row(s)
Quota is disabled
Took 0.0846 seconds

7)将用户表shopping逻辑数据模型中的所有数据写入到shooping表中。

hbase:026:0> put 'eshop:shopping','s001','customer:name','Jack'
Took 0.6497 seconds                                                                            
hbase:027:0> put 'eshop:shopping','s001','customer:phone','00000000001'
Took 0.0513 seconds                                                                            
hbase:028:0> put 'eshop:shopping','s001','customer:address','WuHan'
Took 0.0231 seconds                                                                            
hbase:029:0> put 'eshop:shopping','s001','customer:level','normal'
Took 0.0139 seconds                                                                            
hbase:030:0> put 'eshop:shopping','s001','order:number','1'
Took 0.0282 seconds                                                                            
hbase:031:0> put 'eshop:shopping','s001','order:datetime','2020-4-21'
Took 0.0488 seconds                                                                            
hbase:032:0> put 'eshop:shopping','s001','order:pay-state','not-payed'
Took 0.0215 seconds                                                                            
hbase:033:0> put 'eshop:shopping','s001','item:item_name','iphone8'
Took 0.0396 seconds                                                                            
hbase:034:0> put 'eshop:shopping','s001','item:price','8000.00'
Took 0.0133 seconds
hbase:040:0> put 'eshop:shopping','s002','customer:name','Tom'
Took 0.0170 seconds                                                                                                                    
hbase:041:0> put 'eshop:shopping','s002','customer:phone','00000000002'
Took 0.0196 seconds                                                                                                                    
hbase:042:0> put 'eshop:shopping','s002','customer:address','BeiJing'
Took 0.0214 seconds                                                                                                                    
hbase:043:0> put 'eshop:shopping','s002','customer:preference','e-product'
Took 0.0196 seconds                                                                                                                    
hbase:044:0> put 'eshop:shopping','s002','order:number','2'
Took 0.0150 seconds                                                                                                                    
hbase:045:0> put 'eshop:shopping','s002','order:datetime','2020-4-22'
Took 0.0149 seconds                                                                                                                    
hbase:046:0> put 'eshop:shopping','s002','item:item_name','HUAWEI MATE X2'
Took 0.0471 seconds                                                                                                                    
hbase:047:0> put 'eshop:shopping','s002','item:price','6000.00'
Took 0.0421 seconds 
hbase:053:0> put 'eshop:shopping','s003','customer:name','Mike'
Took 0.0621 seconds                                                                                                                    
hbase:054:0> put 'eshop:shopping','s003','customer:phone','00000000003'
Took 0.0216 seconds                                                                                                                    
hbase:055:0> put 'eshop:shopping','s003','customer:address','Shanghai'
Took 0.0172 seconds                                                                                                                    
hbase:056:0> put 'eshop:shopping','s003','customer:age','20'
Took 0.0390 seconds                                                                                                                    
hbase:057:0> put 'eshop:shopping','s003','order:number','3'
Took 0.0605 seconds                                                                                                                    
hbase:058:0> put 'eshop:shopping','s003','order:datetime','2020-4-23'
Took 0.0120 seconds                                                                                                                    
hbase:059:0> put 'eshop:shopping','s003','item:item_name','XIAO MI 11'
Took 0.0084 seconds                                                                                                                    
hbase:060:0> put 'eshop:shopping','s003','item:price','5000.00'
Took 0.0207 seconds 
hbase:061:0> put 'eshop:shopping','s004','customer:name','Lucy'
Took 0.0157 seconds                                                                                                                    
hbase:062:0> put 'eshop:shopping','s004','customer:phone','00000000004'
Took 0.0085 seconds                                                                                                                    
hbase:063:0> put 'eshop:shopping','s004','customer:address','HangZhou'
Took 0.0165 seconds                                                                                                                    
hbase:064:0> put 'eshop:shopping','s004','customer:preference','cosmetics'
Took 0.0166 seconds                                                                                                                    
hbase:065:0> put 'eshop:shopping','s004','customer:level','VIP'
Took 0.0113 seconds                                                                                                                    
hbase:066:0> put 'eshop:shopping','s004','order:number','4'
Took 0.0145 seconds                                                                                                                    
hbase:067:0> put 'eshop:shopping','s004','order:datetime','202-4-23'
Took 0.0300 seconds                                                                                                                    
hbase:068:0> put 'eshop:shopping','s004','order:pay-state','payed'
Took 0.0086 seconds                                                                                                                    
hbase:069:0> put 'eshop:shopping','s004','order:post_state','recieved'
Took 0.0148 seconds                                                                                                                    
hbase:070:0> put 'eshop:shopping','s004','item:item_name','Lancome'
Took 0.0251 seconds                                                                                                                    
hbase:071:0> put 'eshop:shopping','s004','item:price','10000.00'
Took 0.0289 seconds                                                                                                                    
hbase:072:0> put 'eshop:shopping','s005','customer:name','Lily'
Took 0.0249 seconds                                                                                                                    
hbase:073:0> put 'eshop:shopping','s005','customer:phone','00000000005'
Took 0.0286 seconds                                                                                                                    
hbase:074:0> put 'eshop:shopping','s005','customer:preference','handbag'
Took 0.0263 seconds                                                                                                                    
hbase:075:0> put 'eshop:shopping','s005','customer:level','VIP'
Took 0.0178 seconds                                                                                                                    
hbase:076:0> put 'eshop:shopping','s005','customer:email','abc@qq.com'
Took 0.0237 seconds                                                                                                                    
hbase:077:0> put 'eshop:shopping','s005','order:number','10'
Took 0.0098 seconds                                                                                                                    
hbase:078:0> put 'eshop:shopping','s005','order:datetime','2020-4-23'
Took 0.0211 seconds                                                                                                                    
hbase:079:0> put 'eshop:shopping','s005','order:pay-state','payed'
Took 0.0245 seconds                                                                                                                    
hbase:080:0> put 'eshop:shopping','s005','order:post-state','delivered'
Took 0.0256 seconds                                                                                                                    
hbase:081:0> put 'eshop:shopping','s005','item:item_name','LV'
Took 0.0258 seconds                                                                                                                    
hbase:082:0> put 'eshop:shopping','s005','item:price','20000.00'
Took 0.0199 seconds

8)对shopping表进行全表扫描(读取所有数据行的所有数据列单元格)。

hbase:084:0> scan 'eshop:shopping'
ROW                                COLUMN+CELL                                                                                         s001                              column=customer:address, timestamp=2024-03-22T01:53:27.728, value=WuHan                             s001                              column=customer:level, timestamp=2024-03-22T01:54:02.171, value=normal                              s001                              column=customer:name, timestamp=2024-03-22T02:01:27.551, value=Jack                                 s001                              column=customer:phone, timestamp=2024-03-22T01:52:48.474, value=00000000001                         s001                              column=item:item_name, timestamp=2024-03-22T01:57:17.558, value=iphone8                             s001                              column=item:price, timestamp=2024-03-22T01:57:36.270, value=8000.00                                 s001                              column=order:datetime, timestamp=2024-03-22T01:56:12.975, value=2020-4-21                           s001                              column=order:number, timestamp=2024-03-22T01:55:44.843, value=1                                     s001                              column=order:pay-state, timestamp=2024-03-22T01:56:41.609, value=not-payed                          s002                              column=customer:address, timestamp=2024-03-22T02:03:43.489, value=BeiJing                           s002                              column=customer:name, timestamp=2024-03-22T02:02:58.983, value=Tom                                  s002                              column=customer:phone, timestamp=2024-03-22T02:03:20.715, value=00000000002                         s002                              column=customer:preference, timestamp=2024-03-22T02:04:05.414, value=e-product                      s002                              column=item:item_name, timestamp=2024-03-22T02:05:43.969, value=HUAWEI MATE X2                      s002                              column=item:price, timestamp=2024-03-22T02:06:41.294, value=6000.00                                 s002                              column=order:datetime, timestamp=2024-03-22T02:05:05.397, value=2020-4-22                           s002                              column=order:number, timestamp=2024-03-22T02:04:44.084, value=2                                     s003                              column=customer:address, timestamp=2024-03-22T02:23:25.999, value=Shanghai                          s003                              column=customer:age, timestamp=2024-03-22T02:23:39.768, value=20                                    s003                              column=customer:name, timestamp=2024-03-22T02:22:45.243, value=Mike                                 s003                              column=customer:phone, timestamp=2024-03-22T02:23:08.255, value=00000000003                         s003                              column=item:item_name, timestamp=2024-03-22T02:24:45.930, value=XIAO MI 11                          s003                              column=item:price, timestamp=2024-03-22T02:25:02.682, value=5000.00                                 s003                              column=order:datetime, timestamp=2024-03-22T02:24:17.560, value=2020-4-23                           s003                              column=order:number, timestamp=2024-03-22T02:24:00.754, value=3                                     s004                              column=customer:address, timestamp=2024-03-22T02:26:34.380, value=HangZhou                          s004                              column=customer:level, timestamp=2024-03-22T02:27:35.830, value=VIP                                 s004                              column=customer:name, timestamp=2024-03-22T02:25:44.580, value=Lucy                                 s004                              column=customer:phone, timestamp=2024-03-22T02:26:07.073, value=00000000004                         s004                              column=customer:preference, timestamp=2024-03-22T02:27:17.408, value=cosmetics                      s004                              column=item:item_name, timestamp=2024-03-22T02:29:59.988, value=Lancome                             s004                              column=item:price, timestamp=2024-03-22T02:30:16.339, value=10000.00                                s004                              column=order:datetime, timestamp=2024-03-22T02:28:40.420, value=202-4-23                            s004                              column=order:number, timestamp=2024-03-22T02:28:20.236, value=4                                     s004                              column=order:pay-state, timestamp=2024-03-22T02:28:59.712, value=payed                              s004                              column=order:post_state, timestamp=2024-03-22T02:29:21.588, value=recieved                          s005                              column=customer:email, timestamp=2024-03-22T02:33:56.564, value=abc@qq.com                          s005                              column=customer:level, timestamp=2024-03-22T02:33:34.457, value=VIP                                 s005                              column=customer:name, timestamp=2024-03-22T02:31:36.776, value=Lily                                 s005                              column=customer:phone, timestamp=2024-03-22T02:32:24.128, value=00000000005                         s005                              column=customer:preference, timestamp=2024-03-22T02:33:09.550, value=handbag                        s005                              column=item:item_name, timestamp=2024-03-22T02:36:24.703, value=LV                                  s005                              column=item:price, timestamp=2024-03-22T02:36:40.468, value=20000.00                                s005                              column=order:datetime, timestamp=2024-03-22T02:34:45.746, value=2020-4-23                           s005                              column=order:number, timestamp=2024-03-22T02:34:23.380, value=10                                    s005                              column=order:pay-state, timestamp=2024-03-22T02:35:07.771, value=payed                              s005                              column=order:post-state, timestamp=2024-03-22T02:35:59.275, value=delivered                         
5 row(s)
Took 0.1527 seconds 

9)读取shopping表的行键为s004的所有数据列的单元格值。

hbase:085:0> get 'eshop:shopping','s004'
COLUMN                             CELL                                                                                                customer:address                  timestamp=2024-03-22T02:26:34.380, value=HangZhou                                                   customer:level                    timestamp=2024-03-22T02:27:35.830, value=VIP                                                        customer:name                     timestamp=2024-03-22T02:25:44.580, value=Lucy                                                       customer:phone                    timestamp=2024-03-22T02:26:07.073, value=00000000004                                                customer:preference               timestamp=2024-03-22T02:27:17.408, value=cosmetics                                                  item:item_name                    timestamp=2024-03-22T02:29:59.988, value=Lancome                                                    item:price                        timestamp=2024-03-22T02:30:16.339, value=10000.00                                                   order:datetime                    timestamp=2024-03-22T02:28:40.420, value=202-4-23                                                   order:number                      timestamp=2024-03-22T02:28:20.236, value=4                                                          order:pay-state                   timestamp=2024-03-22T02:28:59.712, value=payed                                                      order:post_state                  timestamp=2024-03-22T02:29:21.588, value=recieved                                                   
1 row(s)
Took 0.3746 seconds

10)读取shopping表的行键s005,列族customer,列限定符preference 的数据列的单元格值。

hbase:087:0> get 'eshop:shopping','s005','customer:preference'
COLUMN                             CELL                                                                                              customer:preference               timestamp=2024-03-22T02:33:09.550, value=handbag                                                  
1 row(s)
Took 0.0361 seconds 

2.对电商平台数据执行复杂读写操作

1)修改shopping表的列族属性,将列族order的列族属性VERSIONS修改为3。

hbase:090:0> alter 'eshop:shopping',NAME=>'order',VERSIONS=>3
Updating all regions with the new schema...
1/1 regions updated.
Done.
Took 6.8406 seconds

2)修改shopping 表的列族属性,将列族order的列族属性TTL生存时间修改为1周,压缩模式修改为gz。

hbase:093:0> alter 'eshop:shopping',NAME=>'info',TTL=>60*60*24*7,COMPRESSION=>'gz'
Updating all regions with the new schema...
1/1 regions updated.
Done.
Took 3.3336 seconds

3)将shopping表的行键为s001,列族为order,列限定符为number 的数据列的单元格值依次修改为2和3。

hbase:094:0> put 'eshop:shopping','s001','order:number',2
Took 0.0721 seconds                                                                                                                  
hbase:095:0> put 'eshop:shopping','s001','order:number',3
Took 0.0368 seconds

4)读取shopping表客户Jack(行键为s001)的订单中商品数量的最近3次的版本值。

hbase:096:0> get 'eshop:shopping','s001',{COLUMN=>'order:number',VERSIONS=>3}
COLUMN                             CELL                                                                                              order:number                      timestamp=2024-03-22T02:54:22.959, value=3                                                        order:number                      timestamp=2024-03-22T02:54:19.466, value=2                                                        order:number                      timestamp=2024-03-22T01:55:44.843, value=1                                                        
1 row(s)
Took 0.1118 seconds 

5)对shopping表指定行键范围s002到s004的数据行进行扫描,扫描结果包括第s002行,也包括第s004行。

hbase:098:0> scan 'eshop:shopping',{STARTROW=>'s002',STOPROW=>'s005'}
ROW                                COLUMN+CELL                                                                                       s002                              column=customer:address, timestamp=2024-03-22T02:03:43.489, value=BeiJing                         s002                              column=customer:name, timestamp=2024-03-22T02:02:58.983, value=Tom                                s002                              column=customer:phone, timestamp=2024-03-22T02:03:20.715, value=00000000002                       s002                              column=customer:preference, timestamp=2024-03-22T02:04:05.414, value=e-product                    s002                              column=item:item_name, timestamp=2024-03-22T02:05:43.969, value=HUAWEI MATE X2                    s002                              column=item:price, timestamp=2024-03-22T02:06:41.294, value=6000.00                               s002                              column=order:datetime, timestamp=2024-03-22T02:05:05.397, value=2020-4-22                         s002                              column=order:number, timestamp=2024-03-22T02:04:44.084, value=2                                   s003                              column=customer:address, timestamp=2024-03-22T02:23:25.999, value=Shanghai                        s003                              column=customer:age, timestamp=2024-03-22T02:23:39.768, value=20                                  s003                              column=customer:name, timestamp=2024-03-22T02:22:45.243, value=Mike                               s003                              column=customer:phone, timestamp=2024-03-22T02:23:08.255, value=00000000003                       s003                              column=item:item_name, timestamp=2024-03-22T02:24:45.930, value=XIAO MI 11                        s003                              column=item:price, timestamp=2024-03-22T02:25:02.682, value=5000.00                               s003                              column=order:datetime, timestamp=2024-03-22T02:24:17.560, value=2020-4-23                         s003                              column=order:number, timestamp=2024-03-22T02:24:00.754, value=3                                   s004                              column=customer:address, timestamp=2024-03-22T02:26:34.380, value=HangZhou                        s004                              column=customer:level, timestamp=2024-03-22T02:27:35.830, value=VIP                               s004                              column=customer:name, timestamp=2024-03-22T02:25:44.580, value=Lucy                               s004                              column=customer:phone, timestamp=2024-03-22T02:26:07.073, value=00000000004                       s004                              column=customer:preference, timestamp=2024-03-22T02:27:17.408, value=cosmetics                    s004                              column=item:item_name, timestamp=2024-03-22T02:29:59.988, value=Lancome                           s004                              column=item:price, timestamp=2024-03-22T02:30:16.339, value=10000.00                              s004                              column=order:datetime, timestamp=2024-03-22T02:28:40.420, value=202-4-23                          s004                              column=order:number, timestamp=2024-03-22T02:28:20.236, value=4                                   s004                              column=order:pay-state, timestamp=2024-03-22T02:28:59.712, value=payed                            s004                              column=order:post_state, timestamp=2024-03-22T02:29:21.588, value=recieved                        
3 row(s)
Took 0.2564 seconds 

6)对shopping表的列族customer 中的所有数据列进行扫描。

hbase:099:0> scan 'eshop:shopping',{COLUMNS=>'customer'}
ROW                                COLUMN+CELL                                                                                       s001                              column=customer:address, timestamp=2024-03-22T01:53:27.728, value=WuHan                           s001                              column=customer:level, timestamp=2024-03-22T01:54:02.171, value=normal                            s001                              column=customer:name, timestamp=2024-03-22T02:01:27.551, value=Jack                               s001                              column=customer:phone, timestamp=2024-03-22T01:52:48.474, value=00000000001                       s002                              column=customer:address, timestamp=2024-03-22T02:03:43.489, value=BeiJing                         s002                              column=customer:name, timestamp=2024-03-22T02:02:58.983, value=Tom                                s002                              column=customer:phone, timestamp=2024-03-22T02:03:20.715, value=00000000002                       s002                              column=customer:preference, timestamp=2024-03-22T02:04:05.414, value=e-product                    s003                              column=customer:address, timestamp=2024-03-22T02:23:25.999, value=Shanghai                        s003                              column=customer:age, timestamp=2024-03-22T02:23:39.768, value=20                                  s003                              column=customer:name, timestamp=2024-03-22T02:22:45.243, value=Mike                               s003                              column=customer:phone, timestamp=2024-03-22T02:23:08.255, value=00000000003                       s004                              column=customer:address, timestamp=2024-03-22T02:26:34.380, value=HangZhou                        s004                              column=customer:level, timestamp=2024-03-22T02:27:35.830, value=VIP                               s004                              column=customer:name, timestamp=2024-03-22T02:25:44.580, value=Lucy                               s004                              column=customer:phone, timestamp=2024-03-22T02:26:07.073, value=00000000004                       s004                              column=customer:preference, timestamp=2024-03-22T02:27:17.408, value=cosmetics                    s005                              column=customer:email, timestamp=2024-03-22T02:33:56.564, value=abc@qq.com                        s005                              column=customer:level, timestamp=2024-03-22T02:33:34.457, value=VIP                               s005                              column=customer:name, timestamp=2024-03-22T02:31:36.776, value=Lily                               s005                              column=customer:phone, timestamp=2024-03-22T02:32:24.128, value=00000000005                       s005                              column=customer:preference, timestamp=2024-03-22T02:33:09.550, value=handbag                      
5 row(s)
Took 0.0883 seconds 

7)对shopping表的列族customer中列名为phone的所有数据列进行扫描。

hbase:100:0> scan 'eshop:shopping',{COLUMNS=>'customer:phone'}
ROW                                COLUMN+CELL                                                                                       s001                              column=customer:phone, timestamp=2024-03-22T01:52:48.474, value=00000000001                       s002                              column=customer:phone, timestamp=2024-03-22T02:03:20.715, value=00000000002                       s003                              column=customer:phone, timestamp=2024-03-22T02:23:08.255, value=00000000003                       s004                              column=customer:phone, timestamp=2024-03-22T02:26:07.073, value=00000000004                       s005                              column=customer:phone, timestamp=2024-03-22T02:32:24.128, value=00000000005                       
5 row(s)
Took 0.0275 seconds

8)对shopping表的前3行数据进行扫描。

hbase:101:0> scan 'eshop:shopping',{LIMIT=>3}
ROW                                COLUMN+CELL                                                                                       s001                              column=customer:address, timestamp=2024-03-22T01:53:27.728, value=WuHan                           s001                              column=customer:level, timestamp=2024-03-22T01:54:02.171, value=normal                            s001                              column=customer:name, timestamp=2024-03-22T02:01:27.551, value=Jack                               s001                              column=customer:phone, timestamp=2024-03-22T01:52:48.474, value=00000000001                       s001                              column=item:item_name, timestamp=2024-03-22T01:57:17.558, value=iphone8                           s001                              column=item:price, timestamp=2024-03-22T01:57:36.270, value=8000.00                               s001                              column=order:datetime, timestamp=2024-03-22T01:56:12.975, value=2020-4-21                         s001                              column=order:number, timestamp=2024-03-22T02:54:22.959, value=3                                   s001                              column=order:pay-state, timestamp=2024-03-22T01:56:41.609, value=not-payed                        s002                              column=customer:address, timestamp=2024-03-22T02:03:43.489, value=BeiJing                         s002                              column=customer:name, timestamp=2024-03-22T02:02:58.983, value=Tom                                s002                              column=customer:phone, timestamp=2024-03-22T02:03:20.715, value=00000000002                       s002                              column=customer:preference, timestamp=2024-03-22T02:04:05.414, value=e-product                    s002                              column=item:item_name, timestamp=2024-03-22T02:05:43.969, value=HUAWEI MATE X2                    s002                              column=item:price, timestamp=2024-03-22T02:06:41.294, value=6000.00                               s002                              column=order:datetime, timestamp=2024-03-22T02:05:05.397, value=2020-4-22                         s002                              column=order:number, timestamp=2024-03-22T02:04:44.084, value=2                                   s003                              column=customer:address, timestamp=2024-03-22T02:23:25.999, value=Shanghai                        s003                              column=customer:age, timestamp=2024-03-22T02:23:39.768, value=20                                  s003                              column=customer:name, timestamp=2024-03-22T02:22:45.243, value=Mike                               s003                              column=customer:phone, timestamp=2024-03-22T02:23:08.255, value=00000000003                       s003                              column=item:item_name, timestamp=2024-03-22T02:24:45.930, value=XIAO MI 11                        s003                              column=item:price, timestamp=2024-03-22T02:25:02.682, value=5000.00                               s003                              column=order:datetime, timestamp=2024-03-22T02:24:17.560, value=2020-4-23                         s003                              column=order:number, timestamp=2024-03-22T02:24:00.754, value=3                                   
3 row(s)
Took 0.1883 seconds 

9)统计shopping表中的数据行数。

hbase:102:0> count 'eshop:shopping'
5 row(s)
Took 0.1783 seconds                                                                                                                  
=> 5

10)删除shopping表的行键为s005,列族为customer,列限定符为email的数据列。

hbase:103:0> delete 'eshop:shopping','s005','customer:email'
Took 0.1145 seconds 

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/763090.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

【医疗-单位计算】

医疗-单位计算 ■ 体重模式下单位计算■ 剂量(mg/kg)■ 剂量速度(mg/kg/h)■ 溶度(mg/ml)■ 运行速度(ml/h) ■ 体重模式下单位计算 ■ 剂量(mg/kg) ■ 剂量…

HTML5+CSS3小实例:具有悬停效果的3D闪耀动画

实例:具有悬停效果的3D闪耀动画 技术栈:HTML+CSS 效果: 源码: 【HTML】 <!DOCTYPE html> <html lang="zh-CN"> <head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, init…

使用python和perl语言实现xlsx转化为csv

下面提供使用 Python 和 Perl 两种常用语言的示例代码&#xff0c;来实现将 Excel 文件 (.xlsx) 转换为 CSV 文件。 首先是 Python 的示例代码&#xff1a; 使用 Python 实现 xlsx 转换为 csv&#xff1a; # 导入所需模块 import pandas as pd# 读取 Excel 文件并写入 CSV 文…

Linux 查看防火墙相关命令

1、查看防火墙状态 systemctl status firewalld 2、启动防火墙 systemctl start/restart firewalld 3、停止防火墙 临时停用&#xff0c;重启后失效 systemctl stop firewalld 4、永久停止防火墙 systemctl disable firewalld 5、开机启动 systemctl enable firew…

2024年卫生巾行业市场分析报告(京东天猫淘宝线上卫生巾品类电商数据查询)

最近&#xff0c;相关部门辟谣了一则“十大致癌卫生巾黑名单”的消息。这个榜单是部分博主AI撰写&#xff0c;为博眼球、蹭热度的结果。此次事件势必会对卫生巾行业产生一定影响&#xff0c;加剧行业竞争。 根据鲸参谋电商数据平台显示&#xff0c;2024年1月至2月线上电商平台…

LeetCode第一天(495.提莫攻击)

题目&#xff1a; 在《英雄联盟》的世界中&#xff0c;有一个叫 “提莫” 的英雄。他的攻击可以让敌方英雄艾希&#xff08;编者注&#xff1a;寒冰射手&#xff09;进入中毒状态。 当提莫攻击艾希&#xff0c;艾希的中毒状态正好持续 duration 秒。 正式地讲&#xff0c;提…

从内存巷弄到指针大道(一)

文章目录 1.内存和地址1.1理解内存地址酒店大堂&#xff1a;内存的入口房间号&#xff1a;内存地址的意义酒店的楼层划分&#xff1a;内存的结构酒店的房间单位&#xff1a;计算机中的常见单位 1.2如何理解编址 2.指针变量和地址2.1取地址操作符&#xff08;&)2.2 指针变量…

姿态生成smpl

目录 Minimal-IK 根据3d姿态预测smpl参数HybrIK smplx_kid_template.npy 下载 h36m_mean_beta.npy下载 h36m_mean_beta.npy 转换脚本

二、typescript基础语法

一、条件语句 二、函数 1、有名函数 function add(x:number, y:number):number {return x y;}2、匿名函数 let add function (x:number, y:number):number {return x y;}函数可选参数 function buildName(firstname: string, lastname?:string) {if (lastname) {return fi…

小程序插件引用vant方式

小程序主体项目构建npm包&#xff0c;引入vant 首先要创建插件&#xff0c;不知道的去官网看下&#xff0c;直通链接 构建npm包&#xff0c;直接在小程序打开终端 npm install npm i vant/weapp -S --production记得修改 project.config.json {..."setting": {...…

模式结果和观测的对比

首先对模式的海表温度进行对比 (base) [chengxllogin02 10yearmean]$ ls sst_*.nc sst_2000.nc sst_2002.nc sst_2004.nc sst_2006.nc sst_2008.nc sst_2001.nc sst_2003.nc sst_2005.nc sst_2007.nc sst_2009.nc 首先将观测资料转化为年平均 ls sst.200* |xargs -I{} cdo -b f…

​2024年保护微服务的前10种技术

1*5rY-jEv7qlpa_swi4WMIBw.png 引言 与当前正在使用的任何其他技术或方法一样&#xff0c;微服务也有其自己的一套缺陷和问题。尽管如此&#xff0c;微服务架构的采用率不断增加&#xff0c;预计到2028年将达到1718.2亿美元。 然而&#xff0c;尽管团队使用微服务&#xff0c;但…

如何默认管理员开启CMD

许多朋友使用win10系统的时候经常会用到CMD命令&#xff0c;而且还要以管理员身份运行&#xff0c;那么如何设置默认打开cmd都是以管理员身份运行&#xff0c;设置的方法挺简单&#xff0c;大家跟着下面的步骤操作即可。 Win10怎么默认以管理员身份运行cmd&#xff1f; 1、在开…

解读 Xend Finance:向 RWA 叙事拓展,构建更具包容性的 DeFi 体系

在二十世纪后&#xff0c;非洲地区陆续爆发了主权运动&#xff0c;这也让非洲大陆逐渐摆脱“殖民地”的标签。目前&#xff0c;非洲大陆公有 54 个主权国家&#xff0c;接近 15 亿且仍在飙升的人口规模&#xff0c;其 GDP 已经与印度相当&#xff0c;且仍旧处于飞速的发展进程中…

【机器学习300问】44、P-R曲线是如何权衡精确率和召回率的?

关于精确率和召回率的基础概念我已经写了两篇文章&#xff0c;如果友友还不知道这两个评估指标是什么&#xff0c;可以先移步去看看这两篇文章&#xff1a; 【机器学习300问】25、常见的模型评估指标有哪些&#xff1f;http://t.csdnimg.cn/JtuUO 总结一下这两个概念&a…

SQL Server 文件组详解

数据文件组 SQL Server 数据库最常用的存储文件是数据文件和日志文件。 数据文件用于存储数据&#xff0c;由一个主要数据文件&#xff08;.mdf&#xff09;和若干个次要数据文件&#xff08;.ndf&#xff09;构成&#xff1b;日志文件用于存储事物日志&#xff0c;由.ldf文件…

Java全栈课程之Linux———基本属性

一、看懂文件属性 Linux系统是一种典型的多用户系统&#xff0c;不同的用户处于不同的地位&#xff0c;拥有不同的权限。为了保护系统的安全性&#xff0c;Linux系统对不同的用户访问同一文件&#xff08;包括目录文件&#xff09;的权限做了不同的规定。 在Linux中我们可以使…

2000元投影仪坚果N1 Air怎么样?对比D5X哪款更好?

投影仪市场&#xff0c;近年来作为家电数码领域的新星&#xff0c;已经引起了广泛的关注。特别是在年轻人群体中&#xff0c;投影仪成为了提升生活品质、享受家庭娱乐时光的重要工具。随着市场的繁荣&#xff0c;各种品牌和型号的投影仪如雨后春笋般涌现&#xff0c;其中&#…

使用 Docker Compose 部署单机版 Redis

第一步&#xff1a;创建 Docker Compose 文件 在你喜欢的文本编辑器中创建一个名为 docker-compose.yml 的文件&#xff0c;并将以下内容复制粘贴进去&#xff1a; version: 3.3 services:redis:image: redis:latestcontainer_name: redisrestart: alwaysports:- 6379:6379vol…

Linux--进程(1)

目录 前言 1.冯诺依曼体系结构 2. 操作系统(Operator System)--第一个被加载的软件 3.进程 3.1基本概念 3.2Linux中的PCB 3.3通过系统调用创建子进程-fork初识 fork&#xff1a;创建一个子进程 为什么要创建子进程&#xff1f; fork的原理&#xff1a; 进一步了解fo…