用hbase反向分页

0sgqnhkj  于 2021-06-09  发布在  Hbase
关注(0)|答案(2)|浏览(404)

我正在进行hbase表分页。我需要实现的功能是,ui分页表应该有next/forward和back/backward特性。
我使用pagefilter实现的forward选项,但是对于backward,我需要从end键到最近的并向后的行(20)。向后获得所有记录1000-980。
我在hbase源代码中找不到任何满足我要求的内容。你知道我们该怎么做吗???
ps:我的行键是多个字段和数据大小(tb)的复合键。

33qvvth1

33qvvth11#

可以从hbase表中的命令行逆序迭代值,也可以对逆序行使用筛选器
example:-

hbase(main):030:0> scan 'test_use'
ROW                                               COLUMN+CELL
 1                                                column=usage:ACP, timestamp=1495474486145, value=3400
 1                                                column=usage:UseTime, timestamp=1495474486145, value=2009-05-16 17:37:13.427
 1                                                column=usage:VisualID, timestamp=1495474486145, value=1
 2                                                column=usage:ACP, timestamp=1495474881861, value=3400
 2                                                column=usage:UseTime, timestamp=1495474881861, value=2009-05-16 17:37:13.427
 2                                                column=usage:VisualID, timestamp=1495474881861, value=2
 3                                                column=usage:ACP, timestamp=1504022698257, value=3.1
 4                                                column=usage:ACP, timestamp=1504022785705, value=4.1
4 row(s) in 0.0930 seconds

hbase(main):031:0> scan 'test_use',{REVERSED=>true}
ROW                                               COLUMN+CELL
 4                                                column=usage:ACP, timestamp=1504022785705, value=4.1
 3                                                column=usage:ACP, timestamp=1504022698257, value=3.1
 2                                                column=usage:ACP, timestamp=1495474881861, value=3400
 2                                                column=usage:UseTime, timestamp=1495474881861, value=2009-05-16 17:37:13.427
 2                                                column=usage:VisualID, timestamp=1495474881861, value=2
 1                                                column=usage:ACP, timestamp=1495474486145, value=3400
 1                                                column=usage:UseTime, timestamp=1495474486145, value=2009-05-16 17:37:13.427
 1                                                column=usage:VisualID, timestamp=1495474486145, value=1
4 row(s) in 0.0500 seconds

hbase(main):032:0> scan 'test_use',{REVERSED=>true,STARTROW=>"1"}
ROW                                               COLUMN+CELL
 1                                                column=usage:ACP, timestamp=1495474486145, value=3400
 1                                                column=usage:UseTime, timestamp=1495474486145, value=2009-05-16 17:37:13.427
 1                                                column=usage:VisualID, timestamp=1495474486145, value=1
1 row(s) in 0.0270 seconds
z2acfund

z2acfund2#

在hbase.98中,有一个新的选项,可以使用非常简单的代码进行反向扫描

scan.setReversed(true);

相关问题