public boolean passesKeyRangeFilter(Scan scan) {
    Optional<ExtendedCell> firstKeyKV = this.getFirstKey();
    Optional<ExtendedCell> lastKeyKV = this.getLastKey();
    if (!firstKeyKV.isPresent() || !lastKeyKV.isPresent()) {
      // the file is empty
      return false;
    }
    if (
      Bytes.equals(scan.getStartRow(), HConstants.EMPTY_START_ROW)
        && Bytes.equals(scan.getStopRow(), HConstants.EMPTY_END_ROW)
    ) {
      return true;
    }
    byte[] smallestScanRow = scan.isReversed() ? scan.getStopRow() : scan.getStartRow();
    byte[] largestScanRow = scan.isReversed() ? scan.getStartRow() : scan.getStopRow();
    boolean nonOverLapping =
      (getComparator().compareRows(firstKeyKV.get(), largestScanRow, 0, largestScanRow.length) > 0
        && !Bytes.equals(scan.isReversed() ? scan.getStartRow() : scan.getStopRow(),
          HConstants.EMPTY_END_ROW))
        || getComparator().compareRows(lastKeyKV.get(), smallestScanRow, 0, smallestScanRow.length)
            < 0;
    return !nonOverLapping;
  }
Checks whether the given scan rowkey range overlaps with the current storefile's
@param scan the scan specification. Used to determine the rowkey range.
@return true if there is overlap, false otherwise
hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/StoreFileReader.java