Support Questions
Find answers, ask questions, and share your expertise
Announcements
Alert: Welcome to the Unified Cloudera Community. Former HCC members be sure to read and learn how to activate your account here.

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

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

New Contributor

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
Highlighted

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

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

Don't have an account?
Coming from Hortonworks? Activate your account here