datefilterhbasedatabase-scan

Hbase - Scan for the last 5 records with date as row key


I have a hbase table with 1 column (Expense) and where date is the row key.

How do i get all the records for the past 5 days? Assuming today's date is 2014-04-13? Which filter to use?

I have the data as below

rowkey           Expense
2014-04-13       128
2014-04-12       57
2014-04-11       10
2014-04-10       100 
2014-04-09       797
2014-04-08       67
2014-04-07       56
2014-04-06       14

Solution

  • mashuai's answer will work just fine, but just to offer an alternative, you can also do a reverse scan:

    Scan scan = new Scan();
    scan.setReversed(true);
    scan.setMaxResultSize(5);