Support Questions
Find answers, ask questions, and share your expertise
Announcements
Check out our newest addition to the community, the Cloudera Innovation Accelerator group hub.

Why it's not possible to iterate through the rows of HBase table in reverse order?

I want to understand in depth concept of the reason behind that if we want to iterate through the values in reverse order-the bytes of the actual value should be written twice.

Thanks with regards!

1 REPLY 1

Super Guru

Hi @Bhaskar Das, you can iterate values in hbase table reverse order and you can use filters for reverse order rows also.

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