static Result filterCells(Result result, ExtendedCell keepCellsAfter) {
    if (keepCellsAfter == null) {
      // do not need to filter
      return result;
    }
    // not the same row
    if (!PrivateCellUtil.matchingRows(keepCellsAfter, result.getRow(), 0, result.getRow().length)) {
      return result;
    }
    ExtendedCell[] rawCells = result.rawExtendedCells();
    int index = Arrays.binarySearch(rawCells, keepCellsAfter,
      CellComparator.getInstance()::compareWithoutRow);
    if (index < 0) {
      index = -index - 1;
    } else {
      index++;
    }
    if (index == 0) {
      return result;
    }
    if (index == rawCells.length) {
      return null;
    }
    return Result.create(Arrays.copyOfRange(rawCells, index, rawCells.length), null,
      result.isStale(), result.mayHaveMoreCellsInRow());
  }
Create a row before the specified row and very close to the specified row.
hbase-client/src/main/java/org/apache/hadoop/hbase/client/ConnectionUtils.java