Add getClosestBefore method to MapFile.Reader
---------------------------------------------

                 Key: HADOOP-2463
                 URL: https://issues.apache.org/jira/browse/HADOOP-2463
             Project: Hadoop
          Issue Type: Improvement
            Reporter: Bryan Duxbury


I have been taking a look at HADOOP-2443, using a sparse cache of HBase 
regions. My plan was to implement this ticket by doing point searches in the 
HBase ROOT and META regions as need be. In order to facilitate this, I need a 
method that will get me the closest key to a given key, but in the less than 
direction. That is, it should find the key that either matches exactly or is 
precisely prior to where it should be. This is necessary because in order to 
find where a given row key belongs in an HBase table, you need to compare it to 
the start keys of all the regions. 

The problem lies in the fact that MapFile.Reader, which stores the ROOT and 
META tables, only support searching in the greater-than-or-equal-to sense. With 
this kind of search, we would always end up exactly one position behind the 
region we're actually looking for. Since there is no back() method to readjust, 
this method would not help us. Basically our only option becomes doing a linear 
search through the MapFile to find the key we're looking for, which would carry 
a significant performance penalty in large regions.

I propose adding a getClosestBefore method that returns the key immediately 
before the the switch from less than or equal to greater than, thus capturing 
the needed key/value. 

-- 
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