0

I am working on hbase table pagination. functionality i need to implement is, UI pagination table should have next/forward and back/backward feature.

Forward option i implemented using PageFilter but for backward, i need to get the rows(20) from end key to most recent and going backward. eg. backward get all records 1000 - 980.

I couldn't find anything in hbase source that would suffice my requirement. any idea how we can implement it???

PS: my row key is a composite key of multiple fields and data size in TB.

Rahul Sharma
  • 5,614
  • 10
  • 57
  • 91

2 Answers2

1

In hbase .98, there is a new option for reverse scan with a so simple code

scan.setReversed(true);
ozhang
  • 171
  • 9
0

you can iterate values from command line in hbase table reverse order and you can use filters for reverse order rows

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
notNull
  • 30,258
  • 4
  • 35
  • 50