*/
private void rowAtOrBeforeCandidate(final MapFile.Reader map,
final HStoreKey sk, final SortedMap<HStoreKey, Long> candidateKeys,
final Set<HStoreKey> deletes, final long now)
throws IOException {
HStoreKey searchKey = sk;
if (searchKey.getHRegionInfo() == null) {
searchKey.setHRegionInfo(this.info);
}
HStoreKey readkey = null;
ImmutableBytesWritable readval = new ImmutableBytesWritable();
HStoreKey knownNoGoodKey = null;
for (boolean foundCandidate = false; !foundCandidate;) {
// Seek to the exact row, or the one that would be immediately before it
readkey = (HStoreKey)map.getClosest(searchKey, readval, true);
if (readkey == null) {
// If null, we are at the start or end of the file.
break;
}
HStoreKey deletedOrExpiredRow = null;
do {
// Set this region into the readkey.
readkey.setHRegionInfo(this.info);
// If we have an exact match on row, and it's not a delete, save this
// as a candidate key
if (HStoreKey.equalsTwoRowKeys(this.info, readkey.getRow(),
searchKey.getRow())) {
if (!HLogEdit.isDeleted(readval.get())) {
if (handleNonDelete(readkey, now, deletes, candidateKeys)) {
foundCandidate = true;
// NOTE! Continue.
continue;
}
}
HStoreKey copy = addCopyToDeletes(readkey, deletes);
if (deletedOrExpiredRow == null) {
deletedOrExpiredRow = copy;
}
} else if (HStoreKey.compareTwoRowKeys(this.info, readkey.getRow(),
searchKey.getRow()) > 0) {
// if the row key we just read is beyond the key we're searching for,
// then we're done.
break;
} else {
// So, the row key doesn't match, but we haven't gone past the row
// we're seeking yet, so this row is a candidate for closest
// (assuming that it isn't a delete).
if (!HLogEdit.isDeleted(readval.get())) {
if (handleNonDelete(readkey, now, deletes, candidateKeys)) {
foundCandidate = true;
// NOTE: Continue
continue;
}
}
HStoreKey copy = addCopyToDeletes(readkey, deletes);
if (deletedOrExpiredRow == null) {
deletedOrExpiredRow = copy;
}
}
} while(map.next(readkey, readval) && (knownNoGoodKey == null ||