Expose getClosestRowBefore in HTable
------------------------------------

                 Key: HBASE-1106
                 URL: https://issues.apache.org/jira/browse/HBASE-1106
             Project: Hadoop HBase
          Issue Type: New Feature
            Reporter: Michael Gottesman
            Priority: Minor


Exposes the functionality of getClosestRowBefore in HTable. It can be useful in 
combination with atomic check and save in the following manner to create a 
global auto-id creation scheme:

Presteps:
1. In your application, have a reserved value.
2. Create a reverse index table of your main table (best algorithm in my 
opinion is bitwise-not of key and append max-utf8 character)
3. Have an offset row in said reverse index table that your application does 
not allow to be set (usually this will be a bitwise inverse of some prefix + 
maximum UTF-8 character)

Algorithm:
1. Use getClosestRowBefore to find the last created row before the offset 
(which will be the last row created)
2. Deinverse key and then increment the row key of the row returned by 
getClosestRowBefore
3. Attempt to reserve the row key with checkAndSave checking if reserved has 
been set.
4. If it fails try again.

Attached is a patch to expose getClosestRowBefore. Comments are of course 
always welcome =).

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to