Java Code Examples for org.apache.hadoop.hbase.io.hfile.HFileScanner#seekBefore()

The following examples show how to use org.apache.hadoop.hbase.io.hfile.HFileScanner#seekBefore() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: HalfStoreFileReader.java    From hbase with Apache License 2.0 6 votes vote down vote up
@Override
public Optional<Cell> getLastKey() {
  if (top) {
    return super.getLastKey();
  }
  // Get a scanner that caches the block and that uses pread.
  HFileScanner scanner = getScanner(true, true);
  try {
    if (scanner.seekBefore(this.splitCell)) {
      return Optional.ofNullable(scanner.getKey());
    }
  } catch (IOException e) {
    LOG.warn("Failed seekBefore " + Bytes.toStringBinary(this.splitkey), e);
  } finally {
    if (scanner != null) {
      scanner.close();
    }
  }
  return Optional.empty();
}
 
Example 2
Source File: TestHalfStoreFileReader.java    From hbase with Apache License 2.0 5 votes vote down vote up
private Cell doTestOfSeekBefore(Path p, FileSystem fs, Reference bottom, Cell seekBefore,
    CacheConfig cacheConfig) throws IOException {
  ReaderContext context = new ReaderContextBuilder().withFileSystemAndPath(fs, p).build();
  HFileInfo fileInfo = new HFileInfo(context, TEST_UTIL.getConfiguration());
  final HalfStoreFileReader halfreader = new HalfStoreFileReader(context, fileInfo, cacheConfig,
      bottom, new AtomicInteger(0), TEST_UTIL.getConfiguration());
  fileInfo.initMetaAndIndex(halfreader.getHFileReader());
  halfreader.loadFileInfo();
  final HFileScanner scanner = halfreader.getScanner(false, false);
  scanner.seekBefore(seekBefore);
  return scanner.getCell();
}