public RowResult getClosestRowBefore(final byte [] row,
final byte [] columnFamily)
throws IOException{
// look across all the HStores for this region and determine what the
// closest key is across all column families, since the data may be sparse
HStoreKey key = null;
checkRow(row);
splitsAndClosesLock.readLock().lock();
try {
HStore store = getStore(columnFamily);
// get the closest key. (HStore.getRowKeyAtOrBefore can return null)
byte [] closestKey = store.getRowKeyAtOrBefore(row);
// If it happens to be an exact match, we can stop.
// Otherwise, we need to check if it's the max and move to the next
if (closestKey != null) {
if (HStoreKey.equalsTwoRowKeys(regionInfo, row, closestKey)) {
key = new HStoreKey(closestKey, this.regionInfo);
}
if (key == null) {
key = new HStoreKey(closestKey, this.regionInfo);
}
}
if (key == null) {
return null;
}
// Now that we've found our key, get the values
HbaseMapWritable<byte [], Cell> cells =
new HbaseMapWritable<byte [], Cell>();
// This will get all results for this store.
store.getFull(key, null, 1, cells);
return new RowResult(key.getRow(), cells);
} finally {
splitsAndClosesLock.readLock().unlock();
}
}