private Cell doTestOfSeekBefore(Path p, FileSystem fs, Reference bottom, ExtendedCell seekBefore,
    CacheConfig cacheConfig) throws IOException {
    ReaderContext context = new ReaderContextBuilder().withFileSystemAndPath(fs, p).build();
    StoreFileInfo storeFileInfo =
      new StoreFileInfo(TEST_UTIL.getConfiguration(), fs, fs.getFileStatus(p), bottom);
    storeFileInfo.initHFileInfo(context);
    final HalfStoreFileReader halfreader =
      (HalfStoreFileReader) storeFileInfo.createReader(context, cacheConfig);
    storeFileInfo.getHFileInfo().initMetaAndIndex(halfreader.getHFileReader());
    halfreader.loadFileInfo();
    try (HFileScanner scanner = halfreader.getScanner(false, false, false)) {
      scanner.seekBefore(seekBefore);
      if (scanner.getCell() != null) {
        return KeyValueUtil.copyToNewKeyValue(scanner.getCell());
      } else {
        return null;
      }
    }
  }
Test the scanner and reseek of a half hfile scanner. The scanner API demands that seekTo and
reseekTo() only return < 0 if the key lies before the start of the file (with no position on
the scanner). Returning 0 if perfect match (rare), and return > 1 if we got an imperfect match.
The latter case being the most common, we should generally be returning 1, and if we do, there
may or may not be a 'next' in the scanner/file. A bug in the half file scanner was returning -1
at the end of the bottom half, and that was causing the infrastructure above to go null causing
NPEs and other problems. This test reproduces that failure, and also tests both the bottom and
top of the file while we are at it.
hbase-server/src/test/java/org/apache/hadoop/hbase/io/TestHalfStoreFileReader.java