最简单的方法就用SCAN加参数STARTROW和ENDROW

hbase(main):024:0> scan 'score',{STARTROW=>'0005',ENDROW=>'0008'}

 输出结果:

ROW COLUMN+CELL 
0005 column=course:Operating System, time
0005 column=grade:order2, timestamp=98, v
0006 column=course:math, timestamp=160533
0006 column=grade:order3, timestamp=16053
0007 column=course:math, timestamp=160533
0007 column=grade:order4, timestamp=92, v
3 row(s) in 0.0330 seconds

 

或者参数和过滤器混用

hbase(main):021:0> scan 'score',{STARTROW=>'0005',FILTER=>"RowFilter(<=,'binary:0007')"}

 输出结果:

ROW COLUMN+CELL 
 0005                                                        column=course:Operating System, timestamp=1605339202987, value=91                                                                                                               
 0005                                                        column=grade:order2, timestamp=98, value=course:math                                                                                                                            
 0006                                                        column=course:math, timestamp=1605339211226, value=95                                                                                                                           
 0006                                                        column=grade:order3, timestamp=1605339603983, value=No.4                                                                                                                        
 0007                                                        column=course:math, timestamp=1605339216074, value=92                                                                                                                           
 0007                                                        column=grade:order4, timestamp=92, value=course:Java                                                                                                                            
3 row(s) in 0.0430 seconds 
hbase(main):022:0> scan 'score',{ENDROW=>'0008',FILTER=>"RowFilter(>=,'binary:0005')"}

输出结果:

ROW                                                          COLUMN+CELL                                                                                                                                                                     
 0005                                                        column=course:Operating System, timestamp=1605339202987, value=91                                                                                                               
 0005                                                        column=grade:order2, timestamp=98, value=course:math                                                                                                                            
 0006                                                        column=course:math, timestamp=1605339211226, value=95                                                                                                                           
 0006                                                        column=grade:order3, timestamp=1605339603983, value=No.4                                                                                                                        
 0007                                                        column=course:math, timestamp=1605339216074, value=92                                                                                                                           
 0007                                                        column=grade:order4, timestamp=92, value=course:Java                                                                                                                            
3 row(s) in 0.0430 seconds

 

两个过滤器的话无法实现,会单执行后面的过滤器

测试输入:

hbase(main):023:0> scan 'score',{FILTER=>"RowFilter(>=,'binary:0005')",FILTER=>"RowFilter(<=,'binary:0007')"}

输出结果:

ROW                                                          COLUMN+CELL                                                                                                                                                                     
 0001                                                        column=course:math, timestamp=1605339168973, value=99                                                                                                                           
 0001                                                        column=grade:order1, timestamp=99, value=course:math                                                                                                                            
 00010                                                       column=course:Java, timestamp=1605339236065, value=97                                                                                                                           
 0002                                                        column=course:english, timestamp=160
 0002                                                        column=grade:order1, timestamp=96, v
 0003                                                        column=course:english, timestamp=160
 0003                                                        column=grade:order1, timestamp=93, v
 0004                                                        column=course:Java, timestamp=160533
 0004                                                        column=course:math, timestamp=160533
 0004                                                        column=grade:order1, timestamp=95, v
 0005                                                        column=course:Operating System, time
 0005                                                        column=grade:order2, timestamp=98, v
 0006                                                        column=course:math, timestamp=160533
 0006                                                        column=grade:order3, timestamp=16053
 0007                                                        column=course:math, timestamp=160533
 0007                                                        column=grade:order4, timestamp=92, v
8 row(s) in 0.0280 seconds