According to my requirements I need to get the first version of specific row in Hbase. Suppose the following Htable:
row_key cf1:c1 timestamp
----------------------------------------
1 x t1
1 x t2
1 x t3
...
Suppose I want to retrieve the first version of row(1) according to timestamp. First, is there any hbase java method for this purpose? Second, if there is not such method can I change the sorting order of timestamp to DESC for retrieving such cell by getting the last version of row(1)? What is the concerns of doing this change to timestamp ordering of hbase?
You can use Result.getColumnCells to get all the columns and then get the first one from the list.
Possible alternative solutions:
Long.MAX_VALUE - System.currentTimeMillis()
. In this case make sure that the maximum number of versions for a cell is high enough otherwise the latest values will be garbage collected by HBase.Have you looked at scan.setReverse(true)? A side note, it's not available in older versions (we use 0.94.18) and is one of motivations for us to upgrade.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With