H 实战案例二之 get 命令【updating…】

1. get 命令

get命令是用来获取H 表中某行的数据

2. 实战案例

在笔者的 h 集群中,有一个表 ns_ct:calllog,在开发过程中,我们不能随便使用scan [tablename] 去获取数据,因为这样会导致扫描整张表。是一个I/O密集型操作。但是在不知道 该表的 行键时 且表数据 较少时,我们可以用scan 获取全部数据,研究其 rowKey ,然后再通过get命令获取每行的数据。
于是,我们可以这么操作:

h (main):025:0> scan \'ns_ct:calllog\'
ROW                                                 COLUMN+CELL                                                                                                                                           
 00_13320266126_20181211184057_18283449398_1_2248   column=f1:build_time, timestamp=1545119528780, value=2018-12-11 18:40:57                                                                              
 00_13320266126_20181211184057_18283449398_1_2248   column=f1:build_time_ts, timestamp=1545119528780, value=1544524857000                                                                                 
 00_13320266126_20181211184057_18283449398_1_2248   column=f1:call1, timestamp=1545119528780, value=13320266126                                                                                           
···    
 04_18907263863_20180127054024_13653454072_1_2799   column=f1:build_time, timestamp=1545119528759, value=2018-01-27 05:40:24                                                                              
 04_18907263863_20180127054024_13653454072_1_2799   column=f1:build_time_ts, timestamp=1545119528759, value=1517002824000                                                                                 
 04_18907263863_20180127054024_13653454072_1_2799   column=f1:call1, timestamp=1545119528759, value=18907263863                                                                                           
 04_18907263863_20180127054024_13653454072_1_2799   column=f1:call2, timestamp=1545119528759, value=13653454072                                                                                           
 04_18907263863_20180127054024_13653454072_1_2799   column=f1:duration, timestamp=1545119528759, value=2799                                                                                               
 04_18907263863_20180127054024_13653454072_1_2799   column=f1:flag, timestamp=1545119528759, value=1                                                                      
 05_18283449398_20180521033943_14218140347_1_395    column=f1:build_time_ts, timestamp=1545119528742, value=1526845183000                                                                                 
 05_18283449398_20180521033943_14218140347_1_395    column=f1:call1, timestamp=1545119528742, value=18283449398                                                                                           
 05_18283449398_20180521033943_14218140347_1_395    column=f1:call2, timestamp=1545119528742, value=14218140347                                                                                           
 05_18283449398_20180521033943_14218140347_1_395    column=f1:duration, timestamp=1545119528742, value=395                                                                                                
 05_18283449398_20180521033943_14218140347_1_395    column=f1:flag, timestamp=1545119528742, value=1                                                                                                      
19 row(s) in 0.2410 seconds

随便选取一个 rowKey,然后使用如下命令获取每行的数据:

h (main):031:0> get \'ns_ct:calllog\', \'04_18907263863_20180127054024_13653454072_1_2799\' 
COLUMN                                              CELL                                                                                                                                                  
 f1:build_time                                      timestamp=1545119528759, value=2018-01-27 05:40:24                                                                                                    
 f1:build_time_ts                                   timestamp=1545119528759, value=1517002824000                                                                                                          
 f1:call1                                           timestamp=1545119528759, value=18907263863                                                                                                            
 f1:call2                                           timestamp=1545119528759, value=13653454072                                                                                                            
 f1:duration                                        timestamp=1545119528759, value=2799                                                                                                                   
 f1:flag                                            timestamp=1545119528759, value=1                                                                                                                      
1 row(s) in 0.0450 seconds

可以看到,在rowKey=04_18907263863_20180127054024_13653454072_1_2799 这行中有

收藏 打印