public int seekTo(ExtendedCell key, boolean rewind) throws IOException {
      HFileBlockIndex.BlockIndexReader indexReader = reader.getDataBlockIndexReader();
      BlockWithScanInfo blockWithScanInfo = indexReader.loadDataBlockWithScanInfo(key, curBlock,
        cacheBlocks, pread, isCompaction, getEffectiveDataBlockEncoding(), reader);
      if (blockWithScanInfo == null || blockWithScanInfo.getHFileBlock() == null) {
        // This happens if the key e.g. falls before the beginning of the file.
        return -1;
      }
      return loadBlockAndSeekToKey(blockWithScanInfo.getHFileBlock(),
        blockWithScanInfo.getNextIndexedKey(), rewind, key, false);
    }
An internal API function. Seek to the given key, optionally rewinding to the first key of the
block before doing the seek.
@param key    - a cell representing the key that we need to fetch
@param rewind whether to rewind to the first key of the block before doing the seek. If this
              is false, we are assuming we never go back, otherwise the result is undefined.
@return -1 if the key is earlier than the first key of the file, 0 if we are at the given
        key, 1 if we are past the given key -2 if the key is earlier than the first key of
        the file while using a faked index key
hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/HFileReaderImpl.java