Re: Reverse sort on Primary Key

2018-04-24 Thread Dan Burkert
The comparator for ScanTokens is based on the partition key, which isn't (necessarily) the same as primary key order. If you have any kind of hash partitioning you will need to do a merge, and if the range partitioning doesn't match the PK then it will be completely different. So, if you set up

Re: Reverse sort on Primary Key

2018-04-23 Thread Scott Reynolds
Thanks guys thought it should be easy. I am looking to paginate through the records, not return the most recent value. If I need to toggle -- which I might -- I was planning on using token api. The KuduScanToken actually implements Comparable and it's implementation is around the tablet. I think

Re: Reverse sort on Primary Key

2018-04-23 Thread Dan Burkert
Hey Scott, Patrick's answer is spot on. I'm curious, though, is your usecase to find the latest value? Effectively a 'SORT BY DESC date LIMIT 1', or are you looking for the last n values, or all values? I ask because we frequently get the 'last value' question, and the solution for that might

Re: Reverse sort on Primary Key

2018-04-23 Thread Patrick Angeles
The common technique is to use (MAX_LONG - timestamp). Unfortunately this won't let you toggle the sort order back-and-forth on the same table. You could have a duplicate table with the inverse key, effectively using it as a secondary index. As of version 0.98, HBase supports a reverse scan