@Override
    public int reseekTo(ExtendedCell key) throws IOException {
      int compared;
      if (isSeeked()) {
        compared = compareKey(reader.getComparator(), key);
        if (compared < 1) {
          // If the required key is less than or equal to current key, then
          // don't do anything.
          return compared;
        } else {
          // The comparison with no_next_index_key has to be checked
          if (
            this.nextIndexedKey != null && (this.nextIndexedKey
                == KeyValueScanner.NO_NEXT_INDEXED_KEY
              || PrivateCellUtil.compareKeyIgnoresMvcc(reader.getComparator(), key, nextIndexedKey)
                  < 0)
          ) {
            // The reader shall continue to scan the current data block instead
            // of querying the
            // block index as long as it knows the target key is strictly
            // smaller than
            // the next indexed key or the current data block is the last data
            // block.
            return loadBlockAndSeekToKey(this.curBlock, nextIndexedKey, false, key, false);
          }
        }
      }
      // Don't rewind on a reseek operation, because reseek implies that we are
      // always going forward in the file.
      return seekTo(key, false);
    }
Within a loaded block, seek looking for the last key that is smaller than (or equal to?) the
key we are interested in. A note on the seekBefore: if you have seekBefore = true, AND the
first key in the block = key, then you'll get thrown exceptions. The caller has to check for
that case and load the previous block as appropriate. the key to find find the key before the
given key in case of exact match.
@return 0 in case of an exact key match, 1 in case of an inexact match, -2 in case of an
        inexact match and furthermore, the input key less than the first key of current
        block(e.g. using a faked index key)
hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/HFileReaderImpl.java